@jsenv/eslint-config-relax 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@jsenv/eslint-config-relax",
3
+ "version": "1.0.0",
4
+ "description": "A pleaseant ESLint configuration for any project",
5
+ "license": "MIT",
6
+ "author": {
7
+ "name": "dmail",
8
+ "email": "dmaillard06@gmail.com"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/jsenv/core",
13
+ "directory": "packages/independent/eslint-config-relax"
14
+ },
15
+ "engines": {
16
+ "node": ">=20.0.0"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "type": "module",
22
+ "exports": {
23
+ ".": {
24
+ "import": "./src/main.js"
25
+ },
26
+ "./*": "./*"
27
+ },
28
+ "files": [
29
+ "/src/"
30
+ ],
31
+ "scripts": {},
32
+ "dependencies": {
33
+ "globals": "15.9.0",
34
+ "@jsenv/eslint-import-resolver": "8.2.0",
35
+ "eslint-plugin-import-x": "3.1.0",
36
+ "eslint-plugin-html": "8.1.1",
37
+ "eslint-plugin-react": "7.35.0",
38
+ "eslint-plugin-regexp": "2.6.0"
39
+ },
40
+ "devDependencies": {}
41
+ }
package/readme.md ADDED
@@ -0,0 +1,3 @@
1
+ # eslint-config-relax
2
+
3
+ [![npm package](https://img.shields.io/npm/v/@jsenv/eslint-config-relax.svg?logo=npm&label=package)](https://www.npmjs.com/package/@jsenv/eslint-config-relax)
@@ -0,0 +1,238 @@
1
+ import babelParser from "@babel/eslint-parser";
2
+ import html from "eslint-plugin-html";
3
+ import pluginImportX from "eslint-plugin-import-x";
4
+ import reactPlugin from "eslint-plugin-react";
5
+ import * as regexpPlugin from "eslint-plugin-regexp";
6
+ import globals from "globals";
7
+ import { explicitGlobals } from "./explicit_globals.js";
8
+ import { rulesImportRelax } from "./rules_import_relax.js";
9
+ import { rulesOffPrettier } from "./rules_off_prettier.js";
10
+ import { rulesReactRelax } from "./rules_react_relax.js";
11
+ import { rulesRegexpRelax } from "./rules_regexp_relax.js";
12
+ import { rulesRelax } from "./rules_relax.js";
13
+
14
+ const patternForEachExtension = (pattern, extensions) => {
15
+ return extensions.map((extension) =>
16
+ pattern.replaceAll("[extension]", extension),
17
+ );
18
+ };
19
+
20
+ export const eslintConfigRelax = ({
21
+ rootDirectoryUrl,
22
+ type = "browser",
23
+ prettier = true,
24
+ prettierSortImport = false,
25
+ jsxPragmaAuto = false,
26
+ importResolutionLogLevel,
27
+
28
+ browserFiles = [],
29
+ browserAndNodeFiles = [],
30
+ } = {}) => {
31
+ const isBrowser = type === "browser";
32
+ const browserExtensions = [".js", ".jsx"];
33
+ browserFiles = [
34
+ "**/*.html",
35
+ ...patternForEachExtension("**/client/**/*[extension]", browserExtensions),
36
+ ...patternForEachExtension("**/www/**/*[extension]", browserExtensions),
37
+ ...patternForEachExtension("**/browser/**/*[extension]", browserExtensions),
38
+ ...(isBrowser
39
+ ? patternForEachExtension("src/**/*[extension]", browserExtensions)
40
+ : []),
41
+ ...browserFiles,
42
+ ];
43
+ browserAndNodeFiles = [...browserAndNodeFiles];
44
+ const parserOptions = {
45
+ ecmaVersion: 2022,
46
+ sourceType: "module",
47
+ ecmaFeatures: { jsx: true },
48
+ };
49
+ const globalsForNodeModule = {
50
+ ...globals.node,
51
+ __filename: "off",
52
+ __dirname: "off",
53
+ require: "off",
54
+ exports: "off",
55
+ ...explicitGlobals,
56
+ };
57
+ const globalsForNodeCommonJs = {
58
+ ...globals.node,
59
+ __filename: false,
60
+ __dirname: false,
61
+ require: false,
62
+ exports: false,
63
+ ...explicitGlobals,
64
+ };
65
+
66
+ return [
67
+ // import plugin
68
+ {
69
+ plugins: {
70
+ "import-x": pluginImportX,
71
+ },
72
+ rules: {
73
+ ...rulesImportRelax,
74
+ // already handled by prettier-plugin-organize-imports}
75
+ ...(prettierSortImport ? { "import-x/no-duplicates": ["off"] } : {}),
76
+ },
77
+ settings: {
78
+ "import-x/extensions": [".js", ".mjs", ".jsx", ".ts", ".tsx"],
79
+ // https://github.com/import-js/eslint-plugin-import/issues/1753
80
+ "import-x/ignore": ["node_modules/playwright/"],
81
+ },
82
+ },
83
+ // node "module" files
84
+ {
85
+ files: ["**/*.js", "**/*.mjs", "**/*.jsx"],
86
+ languageOptions: {
87
+ parser: babelParser,
88
+ parserOptions: {
89
+ ...parserOptions,
90
+ requireConfigFile: false,
91
+ },
92
+ globals: globalsForNodeModule,
93
+ },
94
+ settings: {
95
+ "import-x/resolver": {
96
+ "@jsenv/eslint-import-resolver": {
97
+ rootDirectoryUrl,
98
+ packageConditions: ["node", "development", "import"],
99
+ logLevel: importResolutionLogLevel,
100
+ },
101
+ },
102
+ },
103
+ },
104
+ // node "commonjs" files
105
+ {
106
+ files: ["**/*.cjs"],
107
+ languageOptions: {
108
+ parserOptions: {
109
+ ...parserOptions,
110
+ sourceType: "commonjs",
111
+ },
112
+ globals: globalsForNodeCommonJs,
113
+ },
114
+ settings: {
115
+ "import-x/resolver": {
116
+ "@jsenv/eslint-import-resolver": {
117
+ rootDirectoryUrl,
118
+ packageConditions: ["node", "development"],
119
+ logLevel: importResolutionLogLevel,
120
+ },
121
+ },
122
+ },
123
+ },
124
+ // regexp plugin
125
+ {
126
+ plugins: {
127
+ regexp: regexpPlugin,
128
+ },
129
+ rules: {
130
+ ...rulesRegexpRelax,
131
+ },
132
+ },
133
+ // jsx plugin
134
+ {
135
+ files: ["**/*.jsx"],
136
+ plugins: {
137
+ react: reactPlugin,
138
+ },
139
+ settings: {
140
+ react: {
141
+ version: "detect",
142
+ },
143
+ },
144
+ rules: {
145
+ ...rulesReactRelax,
146
+ ...(jsxPragmaAuto ? { "react/react-in-jsx-scope": ["off"] } : {}),
147
+ },
148
+ },
149
+ // browser files
150
+ {
151
+ files: browserFiles,
152
+ languageOptions: {
153
+ // use "@babel/eslint-parser" because of
154
+ // - top level await
155
+ // - import attributes
156
+ // - decorators
157
+ parser: babelParser,
158
+ parserOptions: {
159
+ ...parserOptions,
160
+ requireConfigFile: false,
161
+ },
162
+ globals: {
163
+ ...globals.browser,
164
+ ...explicitGlobals,
165
+ },
166
+ },
167
+ settings: {
168
+ "import-x/resolver": {
169
+ "@jsenv/eslint-import-resolver": {
170
+ rootDirectoryUrl: String(
171
+ isBrowser
172
+ ? new URL("./src/", rootDirectoryUrl)
173
+ : rootDirectoryUrl,
174
+ ),
175
+ packageConditions: ["browser", "import"],
176
+ logLevel: importResolutionLogLevel,
177
+ },
178
+ },
179
+ },
180
+ },
181
+ // browser and node files
182
+ ...(browserAndNodeFiles.length
183
+ ? [
184
+ {
185
+ files: browserAndNodeFiles,
186
+ languageOptions: {
187
+ parser: babelParser,
188
+ parserOptions: {
189
+ ...parserOptions,
190
+ },
191
+ globals: {
192
+ ...globals.node,
193
+ ...globals.browser,
194
+ ...explicitGlobals,
195
+ },
196
+ },
197
+ },
198
+ ]
199
+ : []),
200
+ {
201
+ rules: {
202
+ ...rulesRelax,
203
+ // We are using prettier, disable all eslint rules
204
+ // already handled by prettier.
205
+ ...(prettier ? rulesOffPrettier : {}),
206
+ },
207
+ },
208
+ // html plugin
209
+ {
210
+ files: ["**/*.html"],
211
+ plugins: { html },
212
+ settings: {
213
+ "html/javascript-mime-types": [
214
+ "text/javascript",
215
+ "module",
216
+ "text/jsx",
217
+ "module/jsx",
218
+ ],
219
+ },
220
+ },
221
+ {
222
+ ignores: [
223
+ "**/.*/**/*",
224
+ "!**/.github/",
225
+ "**/node_modules/",
226
+ "**/git_ignored/",
227
+ "**/old/",
228
+ "**/dist/",
229
+ "**/*.noeslint.*",
230
+ "**/tests/**/**syntax_error**.*",
231
+ "**/tests/**/**syntax_error**/main.html",
232
+ "**/tests/**/snapshots/**/*",
233
+ "**/tests/**/output/**/*",
234
+ "**/tests/**/_*test.*/**/*",
235
+ ],
236
+ },
237
+ ];
238
+ };
@@ -0,0 +1,34 @@
1
+ export const explicitGlobals = {
2
+ alert: "off",
3
+ atob: "off",
4
+ blur: "off",
5
+ btoa: "off",
6
+ caches: "off",
7
+ close: "off",
8
+ closed: "off",
9
+ crypto: "off",
10
+ defaultstatus: "off",
11
+ defaultStatus: "off",
12
+ escape: "off",
13
+ event: "off",
14
+ external: "off",
15
+ focus: "off",
16
+ find: "off",
17
+ frames: "off",
18
+ history: "off",
19
+ length: "off",
20
+ location: "off",
21
+ menubar: "off",
22
+ name: "off",
23
+ navigator: "off",
24
+ open: "off",
25
+ origin: "off",
26
+ print: "off",
27
+ screen: "off",
28
+ scroll: "off",
29
+ status: "off",
30
+ stop: "off",
31
+ top: "off",
32
+ unescape: "off",
33
+ valueOf: "off",
34
+ };
package/src/main.js ADDED
@@ -0,0 +1,2 @@
1
+ export { eslintConfigRelax } from "./eslint_config_relax.js";
2
+ export { rulesRelax } from "./rules_relax.js";
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Contains configuration of ESLint rules when using eslint-plugin-import.
3
+ *
4
+ * Check ./jsenvEslintRules.js to see the mindset used to configure these rules
5
+ */
6
+
7
+ export const rulesImportRelax = {
8
+ "import-x/default": ["error"],
9
+ "import-x/no-unresolved": [
10
+ "error",
11
+ {
12
+ commonjs: true,
13
+ amd: false,
14
+ caseSensitive: false,
15
+ },
16
+ ],
17
+ "import-x/named": ["error"],
18
+ "import-x/namespace": ["error", { allowComputed: true }],
19
+ "import-x/no-absolute-path": ["off"],
20
+ "import-x/no-dynamic-require": ["error"],
21
+ "import-x/export": ["error"],
22
+ "import-x/no-named-as-default": ["warn"],
23
+ "import-x/first": ["warn"],
24
+ "import-x/no-duplicates": ["warn"],
25
+ "import-x/newline-after-import": ["warn"],
26
+ // "import-x/max-dependencies" is not super useful
27
+ // Either you will disable the eslint rule because it's "normal"
28
+ // to have a lot of dependencies or feel compelled to reduce the number of imports.
29
+ // It's already visible that a file has many imports and that ideally they should be
30
+ // less imports, no need for ESLint, let's keep ESLint for more valuable things.
31
+ "import-x/max-dependencies": ["off", { max: 10 }],
32
+ "import-x/no-anonymous-default-export": [
33
+ "off",
34
+ {
35
+ allowArray: true,
36
+ allowArrowFunction: false,
37
+ allowAnonymousClass: false,
38
+ allowAnonymousFunction: false,
39
+ allowLiteral: true,
40
+ allowObject: true,
41
+ },
42
+ ],
43
+ "import-x/no-self-import": ["error"],
44
+ "import-x/no-cycle": ["error"],
45
+ "import-x/no-useless-path-segments": ["error"],
46
+ // named imports are definitely better than import default
47
+ // but some tools expect you to use default export.
48
+ // Also this rules is not that important, in the "relax" spirit there is no need to annoy people with that
49
+ "import-x/no-default-export": ["off"],
50
+ };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * This ESLint config object is setting a list of rules to "off" as they will be already handled by prettier.
3
+ * To ensure rules remains configured to "off", keep eslintConfigForPrettier low, ideally last during eslint composition
4
+ *
5
+ * See also https://github.com/prettier/eslint-config-prettier/blob/master/index.js
6
+ */
7
+
8
+ export const rulesOffPrettier = {
9
+ "arrow-parens": ["off"],
10
+ "arrow-spacing": ["off"],
11
+ "brace-style": ["off"],
12
+ "comma-dangle": ["off"],
13
+ "comma-style": ["off"],
14
+ "computed-property-spacing": ["off"],
15
+ "curly": ["off"],
16
+ "dot-location": ["off"],
17
+ "eol-last": ["off"],
18
+ "generator-star-spacing": ["off"],
19
+ "indent": ["off"],
20
+ "jsx-quotes": ["off"],
21
+ "key-spacing": ["off"],
22
+ "keyword-spacing": ["off"],
23
+ "max-len": ["off"],
24
+ "no-confusing-arrow": ["off"], // prettier makes it non confusing
25
+ "no-extra-semi": ["off"],
26
+ "no-floating-decimal": ["off"],
27
+ "no-mixed-spaces-and-tabs": ["off"],
28
+ "no-multi-spaces": ["off"],
29
+ "no-multi-str": ["off"],
30
+ "no-multiple-empty-lines": ["off"],
31
+ "no-trailing-spaces": ["off"],
32
+ "no-unexpected-multiline": ["off"],
33
+ "no-whitespace-before-property": ["off"],
34
+ "object-curly-spacing": ["off"],
35
+ "one-var-declaration-per-line": ["off"],
36
+ "operator-linebreak": ["off"],
37
+ "padded-blocks": ["off"],
38
+ "quote": ["off"],
39
+ "quote-props": ["off"],
40
+ "semi": ["off"],
41
+ "semi-spacing": ["off"],
42
+ "space-before-blocks": ["off"],
43
+ "space-before-function-paren": ["off"],
44
+ "space-in-parens": ["off"],
45
+ "space-infix-ops": ["off"],
46
+ "template-curly-spacing": ["off"],
47
+ "wrap-iife": ["off"],
48
+ "yield-star-spacing": ["off"],
49
+ };
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Contains configuration of ESLint rules when using eslint-plugin-react.
3
+ *
4
+ * Check ./rules_relax.js to see the mindset used to configure these rules
5
+ */
6
+
7
+ export const rulesReactRelax = {
8
+ "react/display-name": ["error"],
9
+ "react/jsx-key": ["error"],
10
+ "react/jsx-filename-extension": ["error", { extensions: [".jsx"] }],
11
+ "react/jsx-no-comment-textnodes": ["error"],
12
+ "react/jsx-no-duplicate-props": ["error"],
13
+ "react/jsx-no-target-blank": ["off"],
14
+ "react/jsx-no-undef": ["error"],
15
+ "react/jsx-uses-react": ["error"],
16
+ "react/jsx-uses-vars": ["error"],
17
+ "react/no-children-prop": ["error"],
18
+ "react/no-danger-with-children": ["error"],
19
+ "react/no-deprecated": ["error"],
20
+ "react/no-direct-mutation-state": ["error"],
21
+ "react/no-find-dom-node": ["error"],
22
+ "react/no-is-mounted": ["error"],
23
+ "react/no-render-return-value": ["error"],
24
+ "react/no-string-refs": ["error"],
25
+ "react/no-unescaped-entities": ["error"],
26
+ "react/no-unknown-property": ["error"],
27
+ "react/no-unsafe": ["off"],
28
+ "react/prop-types": ["off"],
29
+ "react/react-in-jsx-scope": ["error"],
30
+ "react/require-render-return": ["off"],
31
+ };
@@ -0,0 +1,82 @@
1
+ // https://github.com/ota-meshi/eslint-plugin-regexp/blob/master/lib/configs/rules/recommended.ts
2
+
3
+ const rulesRegexp = {
4
+ // ESLint core rules
5
+ "no-control-regex": "error",
6
+ "no-misleading-character-class": "error",
7
+ "no-regex-spaces": "error",
8
+ "prefer-regex-literals": "error",
9
+ // The ESLint rule will report fewer cases than our rule
10
+ "no-invalid-regexp": "off",
11
+ "no-useless-backreference": "off",
12
+ "no-empty-character-class": "off",
13
+
14
+ // eslint-plugin-regexp rules
15
+ "regexp/confusing-quantifier": "warn",
16
+ "regexp/control-character-escape": "error",
17
+ "regexp/match-any": "error",
18
+ "regexp/negation": "error",
19
+ "regexp/no-contradiction-with-assertion": "error",
20
+ "regexp/no-dupe-characters-character-class": "error",
21
+ "regexp/no-dupe-disjunctions": "error",
22
+ "regexp/no-empty-alternative": "warn",
23
+ "regexp/no-empty-capturing-group": "error",
24
+ "regexp/no-empty-character-class": "error",
25
+ "regexp/no-empty-group": "error",
26
+ "regexp/no-empty-lookarounds-assertion": "error",
27
+ "regexp/no-empty-string-literal": "error",
28
+ "regexp/no-escape-backspace": "error",
29
+ "regexp/no-extra-lookaround-assertions": "error",
30
+ "regexp/no-invalid-regexp": "error",
31
+ "regexp/no-invisible-character": "error",
32
+ "regexp/no-lazy-ends": "warn",
33
+ "regexp/no-legacy-features": "error",
34
+ "regexp/no-misleading-capturing-group": "error",
35
+ "regexp/no-misleading-unicode-character": "error",
36
+ "regexp/no-missing-g-flag": "error",
37
+ "regexp/no-non-standard-flag": "error",
38
+ "regexp/no-obscure-range": "error",
39
+ "regexp/no-optional-assertion": "error",
40
+ "regexp/no-potentially-useless-backreference": "warn",
41
+ "regexp/no-super-linear-backtracking": "error",
42
+ "regexp/no-trivially-nested-assertion": "error",
43
+ "regexp/no-trivially-nested-quantifier": "error",
44
+ "regexp/no-unused-capturing-group": "error",
45
+ "regexp/no-useless-assertions": "error",
46
+ "regexp/no-useless-backreference": "error",
47
+ "regexp/no-useless-character-class": "error",
48
+ "regexp/no-useless-dollar-replacements": "error",
49
+ "regexp/no-useless-escape": "error",
50
+ "regexp/no-useless-flag": "warn",
51
+ "regexp/no-useless-lazy": "error",
52
+ "regexp/no-useless-non-capturing-group": "error",
53
+ "regexp/no-useless-quantifier": "error",
54
+ "regexp/no-useless-range": "error",
55
+ "regexp/no-useless-set-operand": "error",
56
+ "regexp/no-useless-string-literal": "error",
57
+ "regexp/no-useless-two-nums-quantifier": "error",
58
+ "regexp/no-zero-quantifier": "error",
59
+ "regexp/optimal-lookaround-quantifier": "warn",
60
+ "regexp/optimal-quantifier-concatenation": "error",
61
+ "regexp/prefer-character-class": "error",
62
+ "regexp/prefer-d": "error",
63
+ "regexp/prefer-plus-quantifier": "error",
64
+ "regexp/prefer-predefined-assertion": "error",
65
+ "regexp/prefer-question-quantifier": "error",
66
+ "regexp/prefer-range": "error",
67
+ "regexp/prefer-set-operation": "error",
68
+ "regexp/prefer-star-quantifier": "error",
69
+ "regexp/prefer-unicode-codepoint-escapes": "error",
70
+ "regexp/prefer-w": "error",
71
+ "regexp/simplify-set-operations": "error",
72
+ "regexp/sort-flags": "error",
73
+ "regexp/strict": "error",
74
+ "regexp/use-ignore-case": "error",
75
+ };
76
+
77
+ export const rulesRegexpRelax = {
78
+ ...rulesRegexp,
79
+ "regexp/prefer-d": ["off"],
80
+ "regexp/prefer-w": ["off"],
81
+ "regexp/use-ignore-case": ["off"],
82
+ };
@@ -0,0 +1,347 @@
1
+ /*
2
+ * Contains configuration of many ESLint rules with the following mindset:
3
+ * 1. ESLint should fail only for important things
4
+ * 2. ESLint should be silent as long as nothing critical is detected
5
+ * 3. When code is slighly modified to test/debug something, please ESLint, let me do without
6
+ * bothering me with "best practices" and stuff
7
+ *
8
+ * Notes:
9
+ * - Point 3. is the reason why rules like "prefer-const" are disabled
10
+ * - It's on purpose that point "2." is an other way of phrasing "1."
11
+ * - There is a few exception to mindset, for example "no-eval" is not really
12
+ * critical but the rule is still enabled
13
+ *
14
+ * See also:
15
+ * - https://eslint.org/docs/rules/
16
+ */
17
+
18
+ export const rulesRelax = {
19
+ "accessor-pairs": ["error"],
20
+ "array-bracket-spacing": ["error", "never"],
21
+ "array-callback-return": ["error"],
22
+ "arrow-parens": ["error", "as-needed"],
23
+ "arrow-spacing": ["error", { before: true, after: true }],
24
+ "block-scoped-var": ["error"],
25
+ "brace-style": ["error", "stroustrup"],
26
+ "camelcase": [
27
+ "off",
28
+ {
29
+ properties: "always",
30
+ },
31
+ ],
32
+ "comma-dangle": [
33
+ "error",
34
+ {
35
+ arrays: "only-multiline",
36
+ objects: "only-multiline",
37
+ imports: "only-multiline",
38
+ exports: "only-multiline",
39
+ functions: "only-multiline",
40
+ },
41
+ ],
42
+ "comma-spacing": [
43
+ "error",
44
+ {
45
+ before: false,
46
+ after: true,
47
+ },
48
+ ],
49
+ "comma-style": ["error", "last"],
50
+ "computed-property-spacing": ["error", "never"],
51
+ "consistent-return": ["error"],
52
+ "constructor-super": ["error"],
53
+ "curly": ["error"],
54
+ "default-case": ["error"],
55
+ "dot-location": ["error", "property"],
56
+ "dot-notation": ["off"],
57
+ "eol-last": ["off"],
58
+ "eqeqeq": ["error"],
59
+ "generator-star-spacing": ["error", "both"],
60
+ "getter-return": ["error"],
61
+ "grouped-accessor-pairs": ["error"],
62
+ "guard-for-in": ["error"],
63
+ "handle-callback-err": ["warn"],
64
+ /**
65
+ * "tab" is theorically a better option so that people can choose identation width.
66
+ * Because it allow them to decide how much space a tab char takes (2, 4, 100) in their environment
67
+ * But it comes with several issue:
68
+ * - By default github will render a tab with 8 spaces
69
+ * (can be fixed thank to an .editorconfig at the root of the github project (see http://stackoverflow.com/a/33831598)
70
+ * - A user cannot globally defined how much space a tab should take
71
+ * In a perfect world it would be an operating system setting that browser
72
+ * would follow.
73
+ *
74
+ * In practice spaces cause less troubles.
75
+ */
76
+ "indent": ["error", 2, { SwitchCase: 1 }],
77
+ "jsx-quotes": ["error"],
78
+ "key-spacing": [
79
+ "error",
80
+ {
81
+ beforeColon: false,
82
+ afterColon: true,
83
+ },
84
+ ],
85
+ "keyword-spacing": ["error"],
86
+ // disabled otherwise fails when eslint is runned on windows
87
+ // after a git clone
88
+ "linebreak-style": ["off", "unix"],
89
+ "max-len": [
90
+ "warn",
91
+ 120,
92
+ 4,
93
+ {
94
+ ignoreComments: true,
95
+ ignoreUrls: true,
96
+ ignorePattern: "^\\s*var\\s.+=\\s.+\\/.*?\\/;$",
97
+ },
98
+ ],
99
+ "max-nested-callbacks": ["warn", 4],
100
+ "new-cap": [
101
+ "error",
102
+ {
103
+ newIsCap: true,
104
+ capIsNew: false,
105
+ },
106
+ ],
107
+ "new-parens": ["error"],
108
+ "no-alert": ["error"],
109
+ "no-array-constructor": ["error"],
110
+ "no-caller": ["error"],
111
+ "no-case-declarations": ["error"],
112
+ "no-class-assign": ["error"],
113
+ "no-cond-assign": ["error"],
114
+ "no-confusing-arrow": ["error"],
115
+ "no-const-assign": ["error"],
116
+ "no-constant-condition": ["error"],
117
+ "no-constant-binary-expression": ["error"],
118
+ "no-constructor-return": ["error"],
119
+ "no-control-regex": ["error"],
120
+ "no-debugger": process.env.CI ? ["error"] : ["off"],
121
+ "no-delete-var": ["error"],
122
+ "no-div-regex": ["error"],
123
+ "no-dupe-args": ["error"],
124
+ "no-duplicate-case": ["error"],
125
+ "no-dupe-class-members": ["error"],
126
+ "no-dupe-else-if": ["error"],
127
+ "no-dupe-keys": ["error"],
128
+ "no-else-return": ["error"],
129
+ "no-empty-character-class": ["error"],
130
+ "no-empty-pattern": ["error"],
131
+ "no-eq-null": ["error"],
132
+ "no-extend-native": ["error"],
133
+ "no-ex-assign": ["error"],
134
+ "no-extra-bind": ["error"],
135
+ "no-extra-boolean-cast": ["error"],
136
+ "no-extra-label": ["error"],
137
+ "no-extra-semi": ["off"],
138
+ // At first I wanted to disable "no-eval" because every one knows eval is a bad idea
139
+ // so when it's used it's always for a good reason.
140
+ // But on second thought it's better to disable the rule
141
+ // locally using "//eslint-disable-next-line no-eval" in that case
142
+ "no-eval": ["error"],
143
+ "no-fallthrough": ["error"],
144
+ "no-floating-decimal": ["error"],
145
+ "no-func-assign": ["error"],
146
+ "no-inner-declarations": ["error"],
147
+ "no-invalid-regexp": ["error"],
148
+ "no-implicit-coercion": ["error"],
149
+ "no-implicit-globals": ["error"],
150
+ "no-implied-eval": ["error"],
151
+ "no-irregular-whitespace": ["error"],
152
+ "no-iterator": ["error"],
153
+ "no-label-var": ["error"],
154
+ "no-labels": ["off"], // https://gist.github.com/getify/706e5e10822a298375da40f9cc1fa295
155
+ "no-lone-blocks": ["off"], // https://gist.github.com/getify/706e5e10822a298375da40f9cc1fa295
156
+ "no-lonely-if": ["error"],
157
+ "no-loop-func": ["error"],
158
+ "no-magic-numbers": ["off"],
159
+ "no-mixed-requires": ["error", { grouping: true, allowCall: true }],
160
+ "no-mixed-spaces-and-tabs": ["error"],
161
+ "no-multi-spaces": ["error"],
162
+ "no-multi-str": ["error"],
163
+ "no-multiple-empty-lines": ["off", { max: 1 }],
164
+ "no-native-reassign": ["error"],
165
+ "no-negated-condition": ["error"],
166
+ // disabled because deprecated in favor of no-unsafe-negation
167
+ // https://eslint.org/docs/rules/no-negated-in-lhs
168
+ "no-negated-in-lhs": ["off"],
169
+ // I prefer when ESLint really has something to say
170
+ // nested ternary are not wrong, especially when prettier
171
+ // format them correctly
172
+ // In the end, they often gets transformed to helper function
173
+ // but in the meantime eslint is complaining
174
+ "no-nested-ternary": ["off"],
175
+ "no-new": ["error"],
176
+ "no-new-func": ["error"],
177
+ "no-new-require": ["error"],
178
+ "no-new-object": ["error"],
179
+ "no-new-symbol": ["error"],
180
+ "no-new-wrappers": ["error"],
181
+ "no-obj-calls": ["error"],
182
+ "no-octal": ["error"],
183
+ "no-octal-escape": ["error"],
184
+ "no-path-concat": ["error"],
185
+ "no-proto": ["error"],
186
+ "no-redeclare": ["error"],
187
+ "no-regex-spaces": ["error"],
188
+ "no-restricted-imports": [
189
+ "error",
190
+ "domain",
191
+ "freelist",
192
+ "smalloc",
193
+ "sys",
194
+ "colors",
195
+ ],
196
+ "no-restricted-modules": [
197
+ "error",
198
+ "domain",
199
+ "freelist",
200
+ "smalloc",
201
+ "sys",
202
+ "colors",
203
+ ],
204
+ "no-restricted-syntax": ["error", "WithStatement"],
205
+ "no-return-assign": ["error", "always"],
206
+ "no-setter-return": ["error"],
207
+ "no-script-url": ["error"],
208
+ "no-self-assign": ["error"],
209
+ "no-self-compare": ["error"],
210
+ "no-sequences": ["error"],
211
+ "no-shadow-restricted-names": ["error"],
212
+ "no-spaced-func": ["error"],
213
+ "no-sparse-arrays": ["error"],
214
+ "no-this-before-super": ["error"],
215
+ "no-throw-literal": ["error"],
216
+ "no-trailing-spaces": ["error"],
217
+ "no-undef": ["error", { typeof: true }],
218
+ "no-undef-init": ["error"],
219
+ "no-undefined": ["off"],
220
+ "no-unexpected-multiline": ["error"],
221
+ "no-unmodified-loop-condition": ["error"],
222
+ "no-unneeded-ternary": ["error"],
223
+ "no-unreachable": ["error"],
224
+ "no-unused-expressions": ["error"],
225
+ "no-unused-labels": ["off"], // https://gist.github.com/getify/706e5e10822a298375da40f9cc1fa295
226
+ "no-unused-private-class-members": ["error"],
227
+ "no-unused-vars": ["error"],
228
+ "no-use-before-define": [
229
+ "error",
230
+ /*
231
+ * "no-use-before-define" is great to prevent a common mistake
232
+ * where code tries to use a variable before it's actually available.
233
+ * In practice this rule fails even on valid code.
234
+ * Enabling the default options of this rule would
235
+ * force variables,functions and classes to be declared in specific order
236
+ * which is very annoying because:
237
+ * - code is valid in the first place
238
+ * - it's SUPER NICE to put variables and functions that are
239
+ * implementation details at the bottom of the file to make
240
+ * important code more accesible
241
+ */
242
+ {
243
+ functions: false,
244
+ variables: false,
245
+ classes: false,
246
+ allowNamedExports: true,
247
+ },
248
+ ],
249
+ "no-useless-call": ["error"],
250
+ "no-useless-concat": ["error"],
251
+ "no-useless-constructor": ["error"],
252
+ "no-void": ["error"],
253
+ "no-warning-comments": ["off"],
254
+ "no-whitespace-before-property": ["error"],
255
+ "no-with": ["error"],
256
+ "object-curly-spacing": ["error", "always"],
257
+ "object-shorthand": ["warn", "always"],
258
+ "one-var": ["error", "never"],
259
+ "one-var-declaration-per-line": ["error"],
260
+ // Sometimes I prefer to write toto = toto + 1
261
+ // instead of toto++ for whatever reason
262
+ // and having ESLint to complain is annoying
263
+ // I prefer when ESLint really has something to say
264
+ "operator-assignment": ["off", "always"],
265
+ "operator-linebreak": [
266
+ "error",
267
+ "after",
268
+ {
269
+ overrides: { "?": "ignore", ":": "ignore" },
270
+ },
271
+ ],
272
+ "padded-blocks": ["error", "never"],
273
+ // I prefer to use const to indicate immediatly to the reader
274
+ // that this variable is never re-assigned. let becomes
275
+ // the exception and it helps to understand the code.
276
+ // However during development a variable gets used once
277
+ // and should be const, then you reuse it, and should be let.
278
+ // I prefer ESLint to stay quiet during these moments.
279
+ // I already got the habit of using const and would not care
280
+ // if some let where to stay by mistake.
281
+ "prefer-const": [
282
+ "off",
283
+ {
284
+ destructuring: "all",
285
+ ignoreReadBeforeAssign: true,
286
+ },
287
+ ],
288
+ // Math.pow is cool, why being so strict ?
289
+ "prefer-exponentiation-operator": ["off"],
290
+ "prefer-rest-params": ["warn"],
291
+ "prefer-spread": ["warn"],
292
+ "prefer-template": ["warn"],
293
+ "quote": [
294
+ // disabled because it becomes painfull when switching
295
+ // between "" and `` (template literals)
296
+ "off",
297
+ // double because closer to .json, this it increase compatibility between .js and .json
298
+ // also because ' are often used in english and '' would lead to 'I\'m' VS "I'm"
299
+ "double",
300
+ ],
301
+ "quote-props": [
302
+ "error",
303
+ "as-needed",
304
+ {
305
+ keywords: false,
306
+ numbers: true,
307
+ // unnecessary: false so that when you fall into edge cases
308
+ // you can use the quoting style you want
309
+ unnecessary: false,
310
+ },
311
+ ],
312
+ "semi": ["error", "always"],
313
+ "semi-spacing": [
314
+ "error",
315
+ {
316
+ before: false,
317
+ after: true,
318
+ },
319
+ ],
320
+ "space-before-blocks": ["error", "always"],
321
+ "space-before-function-paren": ["error", "never"],
322
+ "space-in-parens": ["error", "never"],
323
+ "space-infix-ops": ["error"],
324
+ "space-unary-ops": ["error"],
325
+ "spaced-comment": [
326
+ "off",
327
+ "always",
328
+ {
329
+ markers: ["!"],
330
+ },
331
+ ],
332
+ "template-curly-spacing": ["error"],
333
+ "use-isnan": ["error"],
334
+ "valid-jsdoc": [
335
+ "off",
336
+ {
337
+ requireReturn: false,
338
+ prefer: {
339
+ returns: "return",
340
+ },
341
+ },
342
+ ],
343
+ "valid-typeof": ["error"],
344
+ "wrap-iife": ["error", "inside"],
345
+ "yield-star-spacing": ["error", "both"],
346
+ "yoda": ["error"],
347
+ };