Skip to content

Commit bbb3fb9

Browse files
chore: configure eslint to warn only on ts files
1 parent 335402d commit bbb3fb9

File tree

2 files changed

+47
-39
lines changed

2 files changed

+47
-39
lines changed

.eslintrc.js

+25-17
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,45 @@ module.exports = {
22
extends: [
33
'plugin:@newrelic/eslint-plugin-newrelic/react',
44
'plugin:@newrelic/eslint-plugin-newrelic/prettier',
5-
'plugin:@typescript-eslint/recommended',
65
'plugin:jsx-a11y/recommended',
76
'plugin:react-hooks/recommended',
87
],
9-
plugins: ['react', 'jsx-a11y', '@typescript-eslint', 'graphql'],
8+
plugins: ['react', 'jsx-a11y', 'graphql'],
109
settings: {
1110
react: {
1211
version: 'detect',
1312
},
1413
},
15-
16-
parser: '@typescript-eslint/parser',
14+
overrides: [
15+
{
16+
files: ['*.ts', '*.tsx'],
17+
extends: [
18+
'plugin:@typescript-eslint/recommended',
19+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
20+
],
21+
parserOptions: {
22+
project: ['./tsconfig.json'],
23+
tsconfigRootDir: __dirname,
24+
},
25+
rules: {
26+
'@typescript-eslint/no-var-requires': 2,
27+
'@typescript-eslint/no-empty-function': 2,
28+
'@typescript-eslint/explicit-module-boundary-types': 2,
29+
'@typescript-eslint/explicit-function-return-type': 2,
30+
'@typescript-eslint/no-unsafe-argument': 2,
31+
'@typescript-eslint/no-use-before-define': 2,
32+
'@typescript-eslint/no-explicit-any': 2,
33+
'@typescript-eslint/camelcase': 2,
34+
},
35+
},
36+
],
1737
parserOptions: {
18-
files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
38+
files: ['*.js', '*.jsx'],
1939
ecmaFeatures: {
2040
jsx: true,
2141
},
2242
ecmaVersion: 2018,
2343
sourceType: 'module',
24-
project: ['./tsconfig.json'],
2544
},
2645
env: {
2746
browser: true,
@@ -46,16 +65,5 @@ module.exports = {
4665
'jsx-a11y/no-onchange': 'off',
4766
'react/react-in-jsx-scope': 'off',
4867
'react/prop-types': 'off',
49-
'@typescript-eslint/no-var-requires': 'off',
50-
'@typescript-eslint/no-empty-function': 'off',
51-
'@typescript-eslint/explicit-module-boundary-types': 1,
52-
'@typescript-eslint/explicit-function-return-type': 1,
53-
'@typescript-eslint/no-unsafe-argument': 1,
54-
'@typescript-eslint/no-use-before-define': 'off',
55-
'@typescript-eslint/no-explicit-any': 1,
56-
57-
// As typescript continuously gets added, we should
58-
// turn this back on.
59-
'@typescript-eslint/camelcase': 'off',
6068
},
6169
};

tsconfig.json

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
2-
"compilerOptions": {
3-
"outDir": "./built",
4-
"allowJs": true,
5-
"jsx": "react-jsx",
6-
"jsxImportSource": "@emotion/react",
7-
"target": "es6",
8-
"moduleResolution": "node",
9-
"sourceMap": true,
10-
"allowSyntheticDefaultImports": true,
11-
"noImplicitAny": true,
12-
"plugins": [
13-
{
14-
"name": "ts-graphql-plugin",
15-
"schema": "src/__generated__/gatsby-schema.graphql",
16-
"tag": "graphql"
17-
}
18-
]
19-
},
20-
// add/remove file paths to include typescript configuration
21-
"include": ["src/**/*", "scripts/**/*", "gatsby/**/*", "gatsby-*.js"],
22-
"exclude": ["node_modules"]
23-
}
2+
"compilerOptions": {
3+
"outDir": "./built",
4+
"allowJs": true,
5+
"jsx": "react-jsx",
6+
"jsxImportSource": "@emotion/react",
7+
"target": "es6",
8+
"moduleResolution": "node",
9+
"sourceMap": true,
10+
"allowSyntheticDefaultImports": true,
11+
"noImplicitAny": true,
12+
"plugins": [
13+
{
14+
"name": "ts-graphql-plugin",
15+
"schema": "src/__generated__/gatsby-schema.graphql",
16+
"tag": "graphql"
17+
}
18+
]
19+
},
20+
"include": ["src/**/*", "scripts/**/*", "gatsby/**/*", "gatsby-*.js"],
21+
"exclude": ["node_modules"]
22+
}
23+

0 commit comments

Comments
 (0)