/
.eslintrc.cjs
71 lines (66 loc) · 1.82 KB
/
.eslintrc.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
This ESLint config is a teeny bit more complex than what I show in my talk...
I added two plugins that auto-sort keys in JS/TS files:
* eslint-plugin-simple-import-sort
* eslint-plugin-typescript-sort-keys
I added eslint-plugin-jsonc to auto-sort keys in .json files
I use the react/jsx-runtime config instead of react/recommended.
See https://github.com/jsx-eslint/eslint-plugin-react#configuration-legacy-eslintrc.
I only enabled typescript-eslint's rules in .ts and .tsx files (see the 'overrides') array.
This way they don't apply to .js files, like this .eslintrc.cjs.
*/
/* eslint-env commonjs, node */
module.exports = {
extends: [
"eslint:recommended",
"plugin:typescript-sort-keys/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
],
overrides: [
{
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
files: ["**/*.{ts,tsx}"],
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json"],
},
rules: {
// I only disabled these so that we wouldn't see later rules
// show up in earlier files... Don't copy these disables! 😉
"@typescript-eslint/await-thenable": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-misused-promises": "off",
},
},
{
files: "*.json",
parser: "jsonc-eslint-parser",
rules: {
"jsonc/sort-keys": "error",
},
extends: ["plugin:jsonc/recommended-with-json"],
},
],
parser: "@typescript-eslint/parser",
plugins: [
"@typescript-eslint",
"react",
"react-hooks",
"simple-import-sort",
"typescript-sort-keys",
],
root: true,
rules: {
"simple-import-sort/exports": "error",
"simple-import-sort/imports": "error",
},
settings: {
react: {
version: "detect",
},
},
};