-
Notifications
You must be signed in to change notification settings - Fork 25
/
.eslintrc.js
157 lines (153 loc) · 5.33 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
requireConfigFile: false,
babelOptions: {
presets: ["@babel/preset-react"]
}
},
extends: [
"airbnb",
// This was added to the RN0.72 template, but it does not work with our current setup
// "@react-native",
"plugin:i18next/recommended",
"plugin:@tanstack/eslint-plugin-query/recommended",
"plugin:react-native-a11y/ios",
"plugin:@typescript-eslint/recommended"
],
plugins: [
"module-resolver",
"react-hooks",
"react-native",
"simple-import-sort",
"@tanstack/query",
"@typescript-eslint"
],
rules: {
"arrow-parens": [2, "as-needed"],
"comma-dangle": [2, "never"],
"consistent-return": [2, { treatUndefinedAsUnspecified: true }],
"func-names": 0,
"global-require": 0,
"i18next/no-literal-string": [
2,
{
words: {
// Minor change to the default to disallow all-caps string literals as well
exclude: ["[0-9!-/:-@[-`{-~]+"]
}
}
],
// The AirBNB approach at
// https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/imports.js#L71
// is quite particular and forbids imports of devDependencies anywhere
// outside of tests and conventional config files, which causes problem
// if you have, say, some utility scripts that have nothing to do with
// your actually application. Here I'm trying to use the defaults
// (https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-extraneous-dependencies.md,
// which allow imports of anything declared in package.json, but should
// raise alarms when you try to import things not declared in
// package.json.
"import/no-extraneous-dependencies": ["error", {}],
"import/extensions": [2, {
js: "never",
jsx: "never",
json: "always"
}],
indent: ["error", 2, { SwitchCase: 1 }],
"max-len": [
"error",
100,
2,
{
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: false,
ignoreTemplateLiterals: false
}
],
"no-alert": 0,
"no-underscore-dangle": 0,
// This gets around eslint problems when typing functions in TS
"no-unused-vars": 0,
"@typescript-eslint/no-unused-vars": [
"error",
{
vars: "all",
args: "after-used",
// Overriding airbnb to allow leading underscore to indicate unused var
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true
}
],
"no-void": 0,
"prefer-destructuring": [2, { object: true, array: false }],
quotes: [2, "double"],
"space-in-parens": [2, "always"],
"max-classes-per-file": 0,
"module-resolver/use-alias": 2,
"multiline-ternary": ["error", "always"],
// At least before we start making production builds
"no-console": 0,
"no-restricted-globals": 0,
"no-param-reassign": 0,
"no-var": 1,
"operator-linebreak": [2, "before"],
"prefer-const": [2, { destructuring: "all" }],
// "react/forbid-prop-types": 0,
"react/prop-types": 0,
"react/destructuring-assignment": 0,
"react/jsx-filename-extension": 0,
"react/function-component-definition": [
2,
{ namedComponents: "arrow-function" }
],
"react/require-default-props": 0,
// React-Hooks Plugin
// The following rules are made available via `eslint-plugin-react-hooks`
"react-hooks/rules-of-hooks": 2,
"react-hooks/exhaustive-deps": 2,
"react-native/no-inline-styles": "error",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"react-native-a11y/has-accessibility-hint": 0,
"react-native-a11y/has-accessibility-props": 1,
"react-native-a11y/has-valid-accessibility-actions": 1,
"react-native-a11y/has-valid-accessibility-role": 1,
"react-native-a11y/has-valid-accessibility-state": 1,
"react-native-a11y/has-valid-accessibility-states": 1,
"react-native-a11y/has-valid-accessibility-component-type": 1,
"react-native-a11y/has-valid-accessibility-traits": 1,
"react-native-a11y/has-valid-accessibility-value": 1,
"react-native-a11y/no-nested-touchables": 1,
"react-native-a11y/has-valid-accessibility-descriptors": 1,
"react-native-a11y/has-valid-accessibility-ignores-invert-colors": 1,
"react-native-a11y/has-valid-accessibility-live-region": 1,
"react-native-a11y/has-valid-important-for-accessibility": 1,
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error",
// it's supposedly safe to remove no-undef because TS's compiler handles
// this, but I'm bumping into this error a lot in VSCode - 20240624 amanda
// https://eslint.org/docs/latest/rules/no-undef#handled_by_typescript
"no-undef": "error",
// TODO: we should actually type these at some point ~amanda 041824
"@typescript-eslint/ban-types": 0,
"@typescript-eslint/no-var-requires": 0
},
// need this so jest doesn't show as undefined in jest.setup.js
env: {
jest: true
},
ignorePatterns: ["/coverage/*", "/vendor/*", "**/flow-typed"],
settings: {
"import/resolver": {
"babel-module": { allowExistingDirectories: true },
node: {
extensions: [".js", ".jsx", ".ts", ".tsx"]
}
}
}
};