-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
165 lines (153 loc) · 6.24 KB
/
eslint.config.mjs
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
158
159
160
161
162
163
164
165
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginReact from "eslint-plugin-react";
import pluginNext from "@next/eslint-plugin-next";
import reactCompiler from 'eslint-plugin-react-compiler';
import reactHooks from "eslint-plugin-react-hooks";
import { includeIgnoreFile } from "@eslint/compat";
import path from "node:path";
import { fileURLToPath } from "node:url";
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
const gitignorePath = path.resolve(dirname, ".gitignore");
/** @type {import("eslint").Linter.Config[]}*/
export default [
{
files: ["**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}"],
},
{
languageOptions: { globals: { ...globals.browser, ...globals.node } },
},
{
ignores: ["src/forks/"],
},
includeIgnoreFile(gitignorePath),
pluginJs.configs.all,
tseslint.configs.base,
pluginReact.configs.flat.all,
{
settings: {
react: {
version: "19.0",
},
},
},
{
plugins: {
'react-compiler': reactCompiler,
'react-hooks': reactHooks,
"@next/next": pluginNext,
},
},
{
settings: {
next: {
rootDir: "src/platforms/next/",
},
},
},
{
rules: {
// covered by EITHER typescript-eslint or TypeScript
"no-unused-vars": "off",
"no-undef": "off",
// Style Guide Rules: Customized
"semi": ["warn", "always", {omitLastInOneLineBlock: true}],
"one-var": ["warn", "never"],
"func-style": ["warn", "declaration", {allowArrowFunctions: true}],
"curly": ["warn", "multi-or-nest", "consistent"],
"react/jsx-wrap-multilines": ["warn", {declaration: "never", assignment: "never", return: "never", arrow: "never", condition: "never", logical: "never", prop: "never"}],
"react/no-multi-comp": ["warn", { "ignoreStateless": true }],
"max-lines": ["warn", {max: 400, skipBlankLines: true, skipComments: true}],
"camelcase": ["warn", {properties: "never", ignoreDestructuring: true, allow: ["__INTERNAL__"]}],
"react/jsx-pascal-case": ["warn", {allowAllCaps: true, ignore: ["*__INTERNAL__*"]}],
"prefer-const": ["warn", {destructuring: "all"}],
"react/jsx-no-useless-fragment": ["warn", {allowExpressions: true}],
"complexity": ["warn", {max: 20, variant: "modified"}], // switches are great! And don't create a lot of mental complexity!
"react/jsx-handler-names": ["warn", {eventHandlerPrefix: "handle", eventHandlerPropPrefix: "off"}], // so we can still use things like `auth.logOut` for our handlers
"react/prefer-read-only-props": ["warn"],
"react/jsx-curly-newline": ["warn", {multiline: "consistent", singleline: "consistent"}],
"react/jsx-max-props-per-line": ["warn", {maximum: {single: 4, multi: 2} }],
"react/self-closing-comp": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "none",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: false, // may need to re-enable this if we start using this feature
}
],
// Logic Rules
"react/jsx-filename-extension": ["error", {extensions: [".jsx", ".tsx"]}],
"react-compiler/react-compiler": "error",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",
//'react-native/no-unused-styles': "off",
//'react-native/no-inline-styles': "off",
//'react-native/no-color-literals': "warn",
//'react-native/sort-styles': "off",
//'react-native/split-platform-components': "error",
//'react-native/no-raw-text': "error",
//'react-native/no-single-element-style-arrays': "off",
// Disabled Rules
"@typescript-eslint/no-console": "off",
"@typescript-eslint/no-unreachable": "off",
"@typescript-eslint/no-extra-parens": "off",
"no-control-regex": "off",
"capitalized-comments": "off",
"sort-imports": "off",
"sort-keys": "off",
"no-magic-numbers": "off",
"no-console": "off",
"no-inline-comments": "off",
"no-use-before-define": "off", // effectively covered by TS
"max-params": "off", // while I do agree with the idea, it's not exactly right for this codebase
"prefer-destructuring": "off",
"no-plusplus": "off",
"id-length": "off",
"no-ternary": "off",
"no-undefined": "off",
"no-continue": "off",
"no-loop-func": "off",
"init-declarations": "off",
"require-atomic-updates": "off",
"react/jsx-props-no-spreading": "off",
"default-case": "off",
"react/jsx-sort-props": "off",
"react/jsx-first-prop-new-line": "off",
"no-lonely-if": "off",
"react/jsx-closing-bracket-location": "off",
"react/jsx-newline": "off",
"new-cap": "off",
"max-statements": "off",
"max-lines-per-function": "off",
"consistent-return": "off",
"no-else-return": "off", // Sorry, but I think it's more readable to put the `else` in there
"no-warning-comments": "off",
"react/react-in-jsx-scope": "off", // Next.js and Expo both handle this in their bundling processes
"react/jsx-max-depth": "off",
"react/jsx-one-expression-per-line": "off",
"react/jsx-no-literals": "off",
"no-negated-condition": "off",
"react/forbid-component-props": "off",
"no-nested-ternary": "off",
"no-promise-executor-return": "off",
"no-underscore-dangle": "off",
"no-param-reassign": "off",
"no-redeclare": "off", // covered by TypeScript, also errors for overflows
"react/destructuring-assignment": "off",
"react/jsx-closing-tag-location": "off", // everything I care about is covered by the rule "react/jsx-indent"
"prefer-arrow-callback": "off", // for components, named functions are more useful
"react/require-default-props": "off", // TS covers everything we'd ever need with this
"no-useless-constructor": "off", // This will throw when using a constructor with properties declared in the constructor
"no-labels": "off",
"no-extra-label": "off",
"consistent-this": "off",
}
}
];