@jsenv/eslint-config-relax 1.1.1 → 1.2.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 +2 -1
- package/readme.md +33 -0
- package/src/eslint_config_relax.js +17 -9
- package/src/rules_relax.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/eslint-config-relax",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A pleaseant ESLint configuration for any project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@babel/eslint-parser": "7.25.1",
|
|
34
34
|
"globals": "15.9.0",
|
|
35
35
|
"@jsenv/eslint-import-resolver": "8.2.0",
|
|
36
|
+
"@jsenv/urls": "2.5.2",
|
|
36
37
|
"eslint-plugin-import-x": "3.1.0",
|
|
37
38
|
"eslint-plugin-html": "8.1.1",
|
|
38
39
|
"eslint-plugin-react": "7.35.0",
|
package/readme.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
1
|
# eslint-config-relax
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@jsenv/eslint-config-relax)
|
|
4
|
+
|
|
5
|
+
Two things:
|
|
6
|
+
|
|
7
|
+
1. ESLint should bother me only for important things
|
|
8
|
+
2. Share ESLint configuration for different types of project
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```console
|
|
13
|
+
npm i --save-dev @jsenv/eslint-config-relax
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**eslint.config.js**
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import { eslintConfigRelax } from "@jsenv/eslint-config-relax";
|
|
20
|
+
|
|
21
|
+
export default eslintConfigRelax({
|
|
22
|
+
rootDirectoryUrl: new URL("./", import.meta.url),
|
|
23
|
+
browserDirectoryUrl: new URL("./src/", import.meta.url), // optional
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Best parts
|
|
28
|
+
|
|
29
|
+
- No need to configure ESLint; it is hard to do correctly
|
|
30
|
+
- Freedom in the code; rules coercing you to code in a certain way are disabled
|
|
31
|
+
- Import resolution works; The whole node esm resolution algorith is implemented
|
|
32
|
+
|
|
33
|
+
## To know
|
|
34
|
+
|
|
35
|
+
- No support for TypeScript (it's planned)
|
|
36
|
+
- Not compatible with ESLint < 8
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import babelParser from "@babel/eslint-parser";
|
|
2
|
+
import { urlToRelativeUrl } from "@jsenv/urls";
|
|
2
3
|
import html from "eslint-plugin-html";
|
|
3
4
|
import pluginImportX from "eslint-plugin-import-x";
|
|
4
5
|
import reactPlugin from "eslint-plugin-react";
|
|
@@ -18,9 +19,18 @@ const patternForEachExtension = (pattern, extensions) => {
|
|
|
18
19
|
);
|
|
19
20
|
};
|
|
20
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Return an ESLint flat config
|
|
24
|
+
* @param {Object} parameters
|
|
25
|
+
* @param {string|url} parameters.rootDirectoryUrl
|
|
26
|
+
* Directory containing the eslint config file and likely your package.json
|
|
27
|
+
* @param {string|url} [parameters.webDirectoryUrl]
|
|
28
|
+
* Directory leading to files that will be executed by a web browser
|
|
29
|
+
* @return {Array} Array of ESLint config objects
|
|
30
|
+
*/
|
|
21
31
|
export const eslintConfigRelax = ({
|
|
22
32
|
rootDirectoryUrl,
|
|
23
|
-
|
|
33
|
+
browserDirectoryUrl,
|
|
24
34
|
prettier,
|
|
25
35
|
prettierSortImport,
|
|
26
36
|
jsxPragmaAuto = false,
|
|
@@ -52,15 +62,17 @@ export const eslintConfigRelax = ({
|
|
|
52
62
|
}
|
|
53
63
|
}
|
|
54
64
|
|
|
55
|
-
const isBrowser = type === "browser";
|
|
56
65
|
const browserExtensions = [".js", ".jsx"];
|
|
57
66
|
browserFiles = [
|
|
58
67
|
"**/*.html",
|
|
59
68
|
...patternForEachExtension("**/client/**/*[extension]", browserExtensions),
|
|
60
69
|
...patternForEachExtension("**/www/**/*[extension]", browserExtensions),
|
|
61
70
|
...patternForEachExtension("**/browser/**/*[extension]", browserExtensions),
|
|
62
|
-
...(
|
|
63
|
-
? patternForEachExtension(
|
|
71
|
+
...(browserDirectoryUrl
|
|
72
|
+
? patternForEachExtension(
|
|
73
|
+
`${urlToRelativeUrl(browserDirectoryUrl, rootDirectoryUrl)}/**/*[extension]`,
|
|
74
|
+
browserExtensions,
|
|
75
|
+
)
|
|
64
76
|
: []),
|
|
65
77
|
...browserFiles,
|
|
66
78
|
];
|
|
@@ -191,11 +203,7 @@ export const eslintConfigRelax = ({
|
|
|
191
203
|
settings: {
|
|
192
204
|
"import-x/resolver": {
|
|
193
205
|
"@jsenv/eslint-import-resolver": {
|
|
194
|
-
rootDirectoryUrl:
|
|
195
|
-
isBrowser
|
|
196
|
-
? new URL("./src/", rootDirectoryUrl)
|
|
197
|
-
: rootDirectoryUrl,
|
|
198
|
-
),
|
|
206
|
+
rootDirectoryUrl: browserDirectoryUrl || rootDirectoryUrl,
|
|
199
207
|
packageConditions: ["browser", "import"],
|
|
200
208
|
logLevel: importResolutionLogLevel,
|
|
201
209
|
},
|
package/src/rules_relax.js
CHANGED
|
@@ -162,7 +162,8 @@ export const rulesRelax = {
|
|
|
162
162
|
"no-multi-str": ["error"],
|
|
163
163
|
"no-multiple-empty-lines": ["off", { max: 1 }],
|
|
164
164
|
"no-native-reassign": ["error"],
|
|
165
|
-
|
|
165
|
+
// theorically great but too often a pain, does not fix the relax mindset
|
|
166
|
+
"no-negated-condition": ["off"],
|
|
166
167
|
// disabled because deprecated in favor of no-unsafe-negation
|
|
167
168
|
// https://eslint.org/docs/rules/no-negated-in-lhs
|
|
168
169
|
"no-negated-in-lhs": ["off"],
|