Repository navigation
Expand file tree
/
Copy patheslint.config.mjs
More file actions
143 lines (129 loc) · 5.46 KB
/
Copy patheslint.config.mjs
File metadata and controls
143 lines (129 loc) · 5.46 KB
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
import js from "@eslint/js";
import react from "eslint-plugin-react";
import jsdoc from "eslint-plugin-jsdoc";
import reactHooks from "eslint-plugin-react-hooks";
import stylisticJs from '@stylistic/eslint-plugin'
import { fileURLToPath } from 'url';
import path from 'path';
import { fixupPluginRules, includeIgnoreFile } from "@eslint/compat";
import globals from "globals";
import babelParser from "@babel/eslint-parser";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const gitIgnorePath = path.resolve(__dirname, ".gitignore")
// To better understand what this configuration is doing and which files it applies to, run:
// yarn run eslint --inspect-config
// It opens a UI client that updates dynamically when making changes in this file, which is also helpful in testing.
export default [
includeIgnoreFile(gitIgnorePath), //ignore git-ignored dirs/files
// vendored third-party source
{ignores: [
"src/firefly/html/gpu-browser.min-*.js",
"src/firefly/js/externalSource/**",
]},
// eslint's recommended rules; the block below layers over these
{files: ["**/*.js", "**/*.jsx"], ...js.configs.recommended},
{
files: ["**/*.js", "**/*.jsx"],
plugins: {
jsdoc,
'@stylistic/js': stylisticJs,
react: fixupPluginRules(react), // compatibility fix for the plugins not yet supporting eslint's new config model: https://eslint.org/blog/2024/05/eslint-compatibility-utilities/
"react-hooks": fixupPluginRules(reactHooks),
},
languageOptions: {
globals: {
...globals.browser,
...globals.jest,
...globals.node
},
parser: babelParser,
ecmaVersion: 2020,
sourceType: "module",
parserOptions: {
requireConfigFile: false,
babelOptions: {
presets: ["@babel/preset-react"],
},
},
},
settings: {
react: {
createClass: "createReactClass", // Regex for Component Factory to use
version: "detect", // React version. "detect" automatically picks the version you have installed.
},
},
rules: {
// 0="off", 1="warn", 2="error"
curly: [2, "multi-line"],
eqeqeq: 1,
"no-console": 0,
"no-empty": 1,
"no-use-before-define": 0,
"no-unused-vars": 1,
"object-shorthand": 1,
"prefer-const": 1,
"prefer-spread": 1,
"prefer-template": 0,
// rules with existing violations: warn until the sites are addressed
"no-case-declarations": 1,
"no-async-promise-executor": 1,
"no-constant-binary-expression": 1,
"no-control-regex": 1,
"no-redeclare": 1,
"no-unsafe-optional-chaining": 1,
"@stylistic/js/arrow-parens": [2, "always"],
"@stylistic/js/comma-spacing": 0,
"@stylistic/js/jsx-quotes": [1, "prefer-single"],
"@stylistic/js/key-spacing": 0,
"@stylistic/js/no-multi-spaces": 0,
"@stylistic/js/semi": [2, "always"],
"@stylistic/js/space-infix-ops": 0,
"@stylistic/js/quotes": [2, "single", {avoidEscape: true, allowTemplateLiterals: "avoidEscape"}],
"react/jsx-boolean-value": [1, "always"],
"react/jsx-no-duplicate-props": 1,
"react/jsx-no-undef": 1,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/jsx-wrap-multilines": 1,
"react/no-danger": 1,
"react/no-did-mount-set-state": 1,
"react/no-did-update-set-state": 1,
"react/no-direct-mutation-state": 1,
"react/no-unknown-property": 1,
"react/prop-types": [1, {
ignore: ["children"],
skipUndeclared: true,
}],
"react/react-in-jsx-scope": 1,
"react/self-closing-comp": 1,
"react-hooks/rules-of-hooks": "error", //checks rules of hooks
'react-hooks/set-state-in-render': 'error',
'react-hooks/globals': 'warn',
'react-hooks/immutability': 'warn',
'react-hooks/purity': 'warn',
'react-hooks/refs': 'warn',
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/config': 'warn',
'react-hooks/error-boundaries': 'warn',
'react-hooks/component-hook-factories': 'warn',
'react-hooks/gating': 'warn',
'react-hooks/preserve-manual-memoization': 'warn',
// 'react-hooks/set-state-in-effect': 'warn',
'react-hooks/static-components': 'warn',
'react-hooks/unsupported-syntax': 'warn',
'react-hooks/use-memo': 'warn',
'react-hooks/incompatible-library': 'warn',
"jsdoc/check-param-names": 1,
"jsdoc/check-tag-names": 0,
"jsdoc/check-types": 0,
"jsdoc/newline-after-description": 0,
"jsdoc/require-description-complete-sentence": 0,
"jsdoc/require-hyphen-before-param-description": 0,
"jsdoc/require-param": 1,
"jsdoc/require-param-description": 0,
"jsdoc/require-param-type": 0,
"jsdoc/require-returns-description": 0,
"jsdoc/require-returns-type": 1,
},
}
];