@jsenv/eslint-config-relax 1.0.1 → 1.1.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/src/eslint_config_relax.js +28 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/eslint-config-relax",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A pleaseant ESLint configuration for any project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
],
|
|
31
31
|
"scripts": {},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@babel/eslint-parser": "7.25.1",
|
|
33
34
|
"globals": "15.9.0",
|
|
34
35
|
"@jsenv/eslint-import-resolver": "8.2.0",
|
|
35
36
|
"eslint-plugin-import-x": "3.1.0",
|
|
@@ -4,6 +4,7 @@ import pluginImportX from "eslint-plugin-import-x";
|
|
|
4
4
|
import reactPlugin from "eslint-plugin-react";
|
|
5
5
|
import * as regexpPlugin from "eslint-plugin-regexp";
|
|
6
6
|
import globals from "globals";
|
|
7
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
7
8
|
import { explicitGlobals } from "./explicit_globals.js";
|
|
8
9
|
import { rulesImportRelax } from "./rules_import_relax.js";
|
|
9
10
|
import { rulesOffPrettier } from "./rules_off_prettier.js";
|
|
@@ -20,14 +21,37 @@ const patternForEachExtension = (pattern, extensions) => {
|
|
|
20
21
|
export const eslintConfigRelax = ({
|
|
21
22
|
rootDirectoryUrl,
|
|
22
23
|
type = "browser",
|
|
23
|
-
prettier
|
|
24
|
-
prettierSortImport
|
|
24
|
+
prettier,
|
|
25
|
+
prettierSortImport,
|
|
25
26
|
jsxPragmaAuto = false,
|
|
26
27
|
importResolutionLogLevel,
|
|
27
28
|
|
|
28
29
|
browserFiles = [],
|
|
29
30
|
browserAndNodeFiles = [],
|
|
30
31
|
} = {}) => {
|
|
32
|
+
const packageJsonFileUrl = new URL("./package.json", import.meta.url);
|
|
33
|
+
let packageObject = {};
|
|
34
|
+
try {
|
|
35
|
+
const packageBuffer = readFileSync(packageJsonFileUrl);
|
|
36
|
+
packageObject = JSON.parse(String(packageBuffer));
|
|
37
|
+
} catch {}
|
|
38
|
+
const { devDependencies = {} } = packageObject;
|
|
39
|
+
if (prettier === undefined) {
|
|
40
|
+
if (devDependencies.prettier || packageObject.prettier) {
|
|
41
|
+
prettier = true;
|
|
42
|
+
} else if (
|
|
43
|
+
existsSync(new URL("./.prettierrc.yml", import.meta.url)) ||
|
|
44
|
+
existsSync(new URL(".prettierignore", import.meta.url))
|
|
45
|
+
) {
|
|
46
|
+
prettier = true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (prettierSortImport === undefined) {
|
|
50
|
+
if (devDependencies["prettier-plugin-organize-imports"]) {
|
|
51
|
+
prettierSortImport = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
31
55
|
const isBrowser = type === "browser";
|
|
32
56
|
const browserExtensions = [".js", ".jsx"];
|
|
33
57
|
browserFiles = [
|
|
@@ -94,7 +118,7 @@ export const eslintConfigRelax = ({
|
|
|
94
118
|
settings: {
|
|
95
119
|
"import-x/resolver": {
|
|
96
120
|
"@jsenv/eslint-import-resolver": {
|
|
97
|
-
rootDirectoryUrl,
|
|
121
|
+
rootDirectoryUrl: String(rootDirectoryUrl),
|
|
98
122
|
packageConditions: ["node", "development", "import"],
|
|
99
123
|
logLevel: importResolutionLogLevel,
|
|
100
124
|
},
|
|
@@ -114,7 +138,7 @@ export const eslintConfigRelax = ({
|
|
|
114
138
|
settings: {
|
|
115
139
|
"import-x/resolver": {
|
|
116
140
|
"@jsenv/eslint-import-resolver": {
|
|
117
|
-
rootDirectoryUrl,
|
|
141
|
+
rootDirectoryUrl: String(rootDirectoryUrl),
|
|
118
142
|
packageConditions: ["node", "development"],
|
|
119
143
|
logLevel: importResolutionLogLevel,
|
|
120
144
|
},
|