11import { printSchema , GraphQLSchema } from "graphql"
2- import { CLIEngine } from "eslint"
2+ import { ESLint } from "eslint"
33import path from "path"
44
55const eslintRulePaths = path . resolve ( `${ __dirname } /eslint-rules` )
66const eslintRequirePreset = require . resolve ( `./eslint/required` )
77
8- export const eslintRequiredConfig : CLIEngine . Options = {
8+ export const eslintRequiredConfig : ESLint . Options = {
99 rulePaths : [ eslintRulePaths ] ,
1010 useEslintrc : false ,
1111 allowInlineConfig : false ,
@@ -19,6 +19,12 @@ export const eslintRequiredConfig: CLIEngine.Options = {
1919 ecmaFeatures : {
2020 jsx : true ,
2121 } ,
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 ,
2228 } ,
2329 globals : {
2430 graphql : true ,
@@ -32,7 +38,7 @@ export const eslintRequiredConfig: CLIEngine.Options = {
3238export const eslintConfig = (
3339 schema : GraphQLSchema ,
3440 usingJsxRuntime : boolean
35- ) : CLIEngine . Options => {
41+ ) : ESLint . Options => {
3642 return {
3743 useEslintrc : false ,
3844 resolvePluginsRelativeTo : __dirname ,
@@ -47,6 +53,20 @@ export const eslintConfig = (
4753 require . resolve ( `eslint-config-react-app` ) ,
4854 eslintRequirePreset ,
4955 ] ,
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+ } ,
5070 plugins : [ `graphql` ] ,
5171 rules : {
5272 // New versions of react use a special jsx runtime that remove the requirement
@@ -75,13 +95,12 @@ export const eslintConfig = (
7595 "jsx-a11y/aria-proptypes" : `warn` ,
7696 "jsx-a11y/aria-role" : `warn` ,
7797 "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+ ] ,
85104 "jsx-a11y/click-events-have-key-events" : `warn` ,
86105 "jsx-a11y/control-has-associated-label" : [
87106 `warn` ,
0 commit comments