-
Notifications
You must be signed in to change notification settings - Fork 296
/
Copy path.eslintrc.js
123 lines (116 loc) · 3.8 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
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const path = require('path');
const workspaceRelative = p => path.resolve(path.join(__dirname, p));
// Set the local directory that contains custom rules
const rulesDirPlugin = require('eslint-plugin-rulesdir');
rulesDirPlugin.RULES_DIR = workspaceRelative('eslint-rules');
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
project: [
workspaceRelative('isl/tsconfig.json'),
workspaceRelative('isl-server/tsconfig.json'),
workspaceRelative('screenshot-tool/tsconfig.json'),
workspaceRelative('shared/tsconfig.json'),
workspaceRelative('components/tsconfig.json'),
workspaceRelative('textmate/tsconfig.json'),
workspaceRelative('vscode/tsconfig.json'),
workspaceRelative('scripts/tsconfig.json'),
],
sourceType: 'module',
},
plugins: [
// Brings the typescript parser used above
'@typescript-eslint',
// enforce rules of hooks and hook dependencies
'react-hooks',
// Sorting imports is maintained by prettier-plugin-organize-imports
'import',
// Allow locally defined custom rules
'rulesdir',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
ignorePatterns: [
'.eslintrc.js',
'isl/build.js',
'isl/release.js',
'isl/start.js',
'isl-server/codegen.js',
// @fb-only
// @fb-only
'node_modules/**',
],
rules: {
// Need to use the TypeScript version of no-unused-vars so it understands
// "private" constructor args.
'@typescript-eslint/no-unused-vars': ['warn', {argsIgnorePattern: '^_'}],
'@typescript-eslint/consistent-type-imports': 'error',
curly: 'error',
'dot-notation': 'error',
'import/no-duplicates': 'error',
// Sorting imports is maintained by prettier-plugin-organize-imports
'import/order': 'off',
'no-await-in-loop': 'error',
'no-bitwise': 'error',
'no-caller': 'error',
'no-console': 'warn',
'no-constant-condition': ['error', {checkLoops: false}],
'no-debugger': 'error',
'no-duplicate-case': 'error',
'no-empty': ['error', {allowEmptyCatch: true}],
'no-eval': 'error',
'no-ex-assign': 'error',
'no-fallthrough': ['error', {commentPattern: '.*'}],
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-param-reassign': 'error',
'no-return-await': 'error',
'no-script-url': 'error',
'no-self-compare': 'error',
'no-unsafe-finally': 'error',
'no-unused-expressions': ['error', {allowShortCircuit: true, allowTernary: true}],
'no-var': 'error',
'no-return-await': 'error',
'object-shorthand': 'error',
'prefer-arrow-callback': 'error',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
'sort-imports': 'off',
yoda: 'error',
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'jotai/utils',
importNames: ['atomFamily'],
message:
'atomFamily leaks memory. Use atomFamilyWeak(keyToAtom), or cached(keyToAtom), or useAtomValue(useMemo(() => keyToAtom(k), [k])), or useAtomGet and useAtomHas instead.',
},
{
name: 'react-dom/test-utils',
importNames: ['act'],
message: 'Prefer importing act from @testing-library/react instead.',
},
],
},
],
// Custom rules
'rulesdir/jotai-maybe-use-family': 'error',
'rulesdir/stylex-import': 'error',
// WARNINGS
'require-await': 'warn',
'no-async-promise-executor': 'warn',
},
};