1
1
import { printSchema , GraphQLSchema } from "graphql"
2
- import { CLIEngine } from "eslint"
2
+ import { ESLint } from "eslint"
3
3
import path from "path"
4
4
5
5
const eslintRulePaths = path . resolve ( `${ __dirname } /eslint-rules` )
6
6
const eslintRequirePreset = require . resolve ( `./eslint/required` )
7
7
8
- export const eslintRequiredConfig : CLIEngine . Options = {
8
+ export const eslintRequiredConfig : ESLint . Options = {
9
9
rulePaths : [ eslintRulePaths ] ,
10
10
useEslintrc : false ,
11
11
allowInlineConfig : false ,
@@ -19,6 +19,12 @@ export const eslintRequiredConfig: CLIEngine.Options = {
19
19
ecmaFeatures : {
20
20
jsx : true ,
21
21
} ,
22
+ // TODO proper check for custom babel & plugins config
23
+ // Currently when a babelrc is added to the project, it will override our babelOptions
24
+ babelOptions : {
25
+ presets : [ `babel-preset-gatsby` ] ,
26
+ } ,
27
+ requireConfigFile : false ,
22
28
} ,
23
29
globals : {
24
30
graphql : true ,
@@ -32,7 +38,7 @@ export const eslintRequiredConfig: CLIEngine.Options = {
32
38
export const eslintConfig = (
33
39
schema : GraphQLSchema ,
34
40
usingJsxRuntime : boolean
35
- ) : CLIEngine . Options => {
41
+ ) : ESLint . Options => {
36
42
return {
37
43
useEslintrc : false ,
38
44
resolvePluginsRelativeTo : __dirname ,
@@ -47,6 +53,20 @@ export const eslintConfig = (
47
53
require . resolve ( `eslint-config-react-app` ) ,
48
54
eslintRequirePreset ,
49
55
] ,
56
+ parser : require . resolve ( `@babel/eslint-parser` ) ,
57
+ parserOptions : {
58
+ ecmaVersion : 2020 ,
59
+ sourceType : `module` ,
60
+ ecmaFeatures : {
61
+ jsx : true ,
62
+ } ,
63
+ // TODO proper check for custom babel & plugins config
64
+ // Currently when a babelrc is added to the project, it will override our babelOptions
65
+ babelOptions : {
66
+ presets : [ `babel-preset-gatsby` ] ,
67
+ } ,
68
+ requireConfigFile : false ,
69
+ } ,
50
70
plugins : [ `graphql` ] ,
51
71
rules : {
52
72
// New versions of react use a special jsx runtime that remove the requirement
@@ -75,13 +95,12 @@ export const eslintConfig = (
75
95
"jsx-a11y/aria-proptypes" : `warn` ,
76
96
"jsx-a11y/aria-role" : `warn` ,
77
97
"jsx-a11y/aria-unsupported-elements" : `warn` ,
78
- // TODO: It looks like the `autocomplete-valid` rule hasn't been published yet
79
- // "jsx-a11y/autocomplete-valid": [
80
- // "warn",
81
- // {
82
- // inputComponents: [],
83
- // },
84
- // ],
98
+ "jsx-a11y/autocomplete-valid" : [
99
+ `warn` ,
100
+ {
101
+ inputComponents : [ ] ,
102
+ } ,
103
+ ] ,
85
104
"jsx-a11y/click-events-have-key-events" : `warn` ,
86
105
"jsx-a11y/control-has-associated-label" : [
87
106
`warn` ,
0 commit comments