forked from devfile/landing-page
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.json
135 lines (135 loc) · 4.81 KB
/
.eslintrc.json
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
{
"plugins": ["eslint-comments", "promise", "unicorn"],
"extends": [
"airbnb",
"airbnb/hooks",
"plugin:eslint-comments/recommended",
"plugin:promise/recommended",
"plugin:unicorn/recommended",
"prettier",
"next"
],
"env": {
"browser": true,
"node": true
},
"settings": {
"react": {
"version": "detect"
}
},
"parserOptions": {
"project": "./tsconfig.json",
"ecmaVersion": 13,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
// React is already in-scope for all files compiled with Next.js
"react/react-in-jsx-scope": "off",
// SSR does not support useLayoutEffect
"no-restricted-imports": [
"error",
{
"name": "react",
"importNames": ["useLayoutEffect"],
"message": "`useLayoutEffect` causes a warning in SSR. Use `useEffect`"
}
],
// Enables for of and for in loops since airbnb does not allow them
"no-restricted-syntax": "off",
// Enforces camelcase
"camelcase": [
"error",
{
"ignoreDestructuring": true
}
],
// Too restrictive, writing ugly code to defend against a very unlikely scenario: https://eslint.org/docs/rules/no-prototype-builtins
"no-prototype-builtins": "off",
// Does not allow unreachable loops unless its a for of loop
"no-unreachable-loop": ["error", { "ignore": ["ForInStatement", "ForOfStatement"] }],
// The default case may not be necessary when explicitly knowing return types
"default-case": "warn",
// Can make ugly code
"consistent-return": "off",
// Can make ugly code
"no-case-declarations": "off",
// Too restrictive: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
"react/destructuring-assignment": "off",
// No jsx extension: https://github.com/facebook/create-react-app/issues/87#issuecomment-234627904
"react/jsx-filename-extension": "off",
// Allow only arrow function based components
"react/function-component-definition": [2, { "namedComponents": "arrow-function" }],
// Common practice in React
"react/jsx-props-no-spreading": "off",
// Warn when the index is used as a key instead of a unique value
"react/no-array-index-key": "warn",
// Sometimes its useful to return a useless fragment instead of adding a null as a union type
"react/jsx-no-useless-fragment": "warn",
// Common abbreviations are known and readable
"unicorn/prevent-abbreviations": "off",
// Airbnb prefers forEach
"unicorn/no-array-for-each": "off",
// React prefers capitalized file names for components
"unicorn/filename-case": "off",
// Enables Array.reduce()
"unicorn/no-array-reduce": "off",
// https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
"import/prefer-default-export": "off",
// It's not accurate in the monorepo style
"import/no-extraneous-dependencies": "off",
// Import for import of components
"import/no-cycle": "off"
},
"overrides": [
{
"files": ["**/*.js"],
"rules": {
// Allow CJS until ESM support improves
"unicorn/prefer-module": "off"
}
},
{
"files": ["**/*.ts", "**/*.tsx"],
"plugins": ["@typescript-eslint"],
"extends": [
"airbnb-typescript",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"parser": "@typescript-eslint/parser",
"rules": {
// It's not accurate in the monorepo style
"import/no-extraneous-dependencies": "off",
// Requires return type
"@typescript-eslint/explicit-function-return-type": "error",
// Allows the use of functions before definition
"@typescript-eslint/no-use-before-define": ["off"],
// Allows variables starting with _ to be ignored if not used
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_"
}
],
// Disallows function overloading
"@typescript-eslint/unified-signatures": "error",
// Requires function return types
"@typescript-eslint/prefer-function-type": "error",
// Requires classes to make member access explicit
"@typescript-eslint/explicit-member-accessibility": "error",
// Requires the use of interface over type when possible
"@typescript-eslint/consistent-type-definitions": "error",
// Requires consistent type casting
"@typescript-eslint/consistent-type-assertions": "error",
// Requires the T[] type syntax for an array
"@typescript-eslint/array-type": "error",
// Next.js does not require all anchor tags to have an href
"jsx-a11y/anchor-is-valid": "off"
}
}
]
}