-
Notifications
You must be signed in to change notification settings - Fork 7
/
.eslintrc.js
121 lines (121 loc) · 3.35 KB
/
.eslintrc.js
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// https://robertcooper.me/post/using-eslint-and-prettier-in-a-typescript-project
module.exports = {
env: {
browser: true,
es6: true,
jest: true,
node: true,
},
// Excludes config files from linting
ignorePatterns: ["rollup.config.mjs"],
// Specifies the ESLint parser
extends: [
"plugin:import/recommended",
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jsx-a11y/recommended",
"airbnb-typescript",
"plugin:sonarjs/recommended",
"plugin:storybook/recommended",
"plugin:prettier/recommended",
"plugin:react-hooks/recommended",
],
// this is to disable
// no-unused-var, no-extraneous-dependencies and prettier
// rules in all ComponentName.namespace.tsx files
overrides: [
{
files: ["packages/**/src/core/**/*.namespace-test.tsx"],
rules: {
"@typescript-eslint/no-unused-vars": "off",
"import/no-extraneous-dependencies": "off",
"prettier/prettier": "off",
},
},
],
parser: "@typescript-eslint/parser",
parserOptions: {
createDefaultProgram: true,
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2020,
// Allows for the use of imports
project: "./tsconfig.json",
// Allows for the parsing of modern ECMAScript features
sourceType: "module",
},
plugins: ["@typescript-eslint", "react", "sonarjs", "jest", "jsx-a11y"],
rules: {
"@typescript-eslint/ban-types": [
"error",
{
types: {
"React.FC": {
fixWith: "React.FC",
message:
"Use implicit return type, define props as parameters instead. More: https://github.com/facebook/create-react-app/pull/8177",
},
},
},
],
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "after-used",
argsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-use-before-define": "off",
"consistent-return": "off",
"import/extensions": [
"error",
"ignorePackages",
{
js: "never",
jsx: "never",
ts: "never",
tsx: "never",
},
],
"import/no-anonymous-default-export": "error",
"import/no-extraneous-dependencies": [
"error",
{
// Dependencies must be specified in `devDependencies` in the monorepo root
devDependencies: true,
packageDir: __dirname,
},
],
"import/prefer-default-export": "off",
// (thuang): Disable this line for `@typescript-eslint/no-unused-vars` to work
"no-unused-vars": "off",
"react/display-name": "off",
"react/jsx-no-target-blank": "off",
"react/jsx-props-no-spreading": "off",
// (thuang): Disable this since we use TypeScript
"react/jsx-uses-react": "off",
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
// (thuang): DefaultProps is being deprecated
// https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/default_props/
"react/require-default-props": "off",
// (thuang): We use nested template literals in @emotion extensively
"sonarjs/no-nested-template-literals": "off",
"sort-keys": [
"error",
"asc",
{
caseSensitive: true,
minKeys: 2,
natural: false,
},
],
},
settings: {
react: {
version: "detect",
},
},
};