@jsenv/eslint-config-relax 1.7.7 → 1.7.9
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 -2
- package/src/eslint_config_relax.js +49 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/eslint-config-relax",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.9",
|
|
4
4
|
"description": "A pleaseant ESLint configuration for any project",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@babel/eslint-parser": "7.28.5",
|
|
28
28
|
"@jsenv/eslint-import-resolver": "8.4.2",
|
|
29
29
|
"@jsenv/eslint-plugin": "1.1.0",
|
|
30
|
-
"@jsenv/urls": "2.9.
|
|
30
|
+
"@jsenv/urls": "2.9.4",
|
|
31
31
|
"eslint-plugin-html": "8.1.3",
|
|
32
32
|
"eslint-plugin-import-x": "4.16.1",
|
|
33
33
|
"eslint-plugin-react": "7.37.5",
|
|
@@ -24,13 +24,49 @@ const patternForEachExtension = (pattern, extensions) => {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* @param {
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
27
|
+
* Creates a comprehensive ESLint flat configuration with relaxed rules and automatic detection
|
|
28
|
+
* of project settings. Supports React/Preact, Prettier integration, browser/Node.js environments,
|
|
29
|
+
* and smart defaults based on your package.json dependencies.
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} parameters - Configuration options
|
|
32
|
+
* @param {string|URL} parameters.rootDirectoryUrl - Directory containing the eslint config file and likely your package.json
|
|
33
|
+
* @param {string|URL} [parameters.browserDirectoryUrl] - Directory containing files that will be executed by a web browser (formerly webDirectoryUrl)
|
|
34
|
+
* @param {boolean} [parameters.prettier] - Enable Prettier integration. Auto-detected from package.json if not specified
|
|
35
|
+
* @param {boolean} [parameters.prettierSortImport] - Enable prettier-plugin-organize-imports integration. Auto-detected if not specified
|
|
36
|
+
* @param {boolean} [parameters.jsxPragmaAuto=false] - Disable react/react-in-jsx-scope rule for automatic JSX pragma
|
|
37
|
+
* @param {boolean} [parameters.preact] - Enable Preact-specific settings. Auto-detected from package.json if not specified
|
|
38
|
+
* @param {string} [parameters.reactVersion="detect"] - React version for eslint-plugin-react. Defaults to auto-detection
|
|
39
|
+
* @param {string} [parameters.reactVersionForPreact="19.2.0"] - React version to use when preact is detected
|
|
40
|
+
* @param {string} [parameters.importResolutionLogLevel] - Log level for import resolution debugging
|
|
41
|
+
* @param {string[]} [parameters.importResolutionDevConditions=[]] - Additional package.json conditions for import resolution in development
|
|
42
|
+
* @param {string[]} [parameters.browserFiles=[]] - Additional glob patterns for files that should use browser environment. Extends default patterns
|
|
43
|
+
* @param {string[]} [parameters.browserAndNodeFiles=[]] - Glob patterns for files that run in both browser and Node.js environments
|
|
44
|
+
*
|
|
45
|
+
* @returns {Array<Object>} Array of ESLint flat config objects configured with:
|
|
46
|
+
* - Relaxed rules optimized for development productivity
|
|
47
|
+
* - Automatic browser/Node.js environment detection
|
|
48
|
+
* - React/Preact JSX support with proper settings
|
|
49
|
+
* - Import resolution with package.json conditions
|
|
50
|
+
* - HTML file linting support
|
|
51
|
+
* - Prettier integration when detected
|
|
52
|
+
* - Smart ignores for common directories
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* // Basic usage with auto-detection
|
|
56
|
+
* import { eslintConfigRelax } from "@jsenv/eslint-config-relax";
|
|
57
|
+
* export default eslintConfigRelax({
|
|
58
|
+
* rootDirectoryUrl: import.meta.url
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* // With custom browser directory and explicit settings
|
|
63
|
+
* export default eslintConfigRelax({
|
|
64
|
+
* rootDirectoryUrl: import.meta.url,
|
|
65
|
+
* browserDirectoryUrl: new URL("./src/client/", import.meta.url),
|
|
66
|
+
* prettier: true,
|
|
67
|
+
* preact: true,
|
|
68
|
+
* browserFiles: ["src/frontend/**"]
|
|
69
|
+
* });
|
|
34
70
|
*/
|
|
35
71
|
export const eslintConfigRelax = ({
|
|
36
72
|
rootDirectoryUrl,
|
|
@@ -83,16 +119,17 @@ export const eslintConfigRelax = ({
|
|
|
83
119
|
...patternForEachExtension("**/browser/**/*[extension]", browserExtensions),
|
|
84
120
|
];
|
|
85
121
|
if (browserDirectoryUrl) {
|
|
86
|
-
let
|
|
122
|
+
let browserDirectoryUrlString = String(browserDirectoryUrl);
|
|
123
|
+
if (!browserDirectoryUrlString.endsWith("/")) {
|
|
124
|
+
browserDirectoryUrlString += "/";
|
|
125
|
+
}
|
|
126
|
+
const relativeBrowserDir = urlToRelativeUrl(
|
|
87
127
|
browserDirectoryUrl,
|
|
88
128
|
rootDirectoryUrl,
|
|
89
129
|
);
|
|
90
|
-
if (relativeBrowserDir.endsWith("/")) {
|
|
91
|
-
relativeBrowserDir = relativeBrowserDir.slice(0, -1);
|
|
92
|
-
}
|
|
93
130
|
defaultBrowserFiles.push(
|
|
94
131
|
...patternForEachExtension(
|
|
95
|
-
`${relativeBrowserDir}
|
|
132
|
+
`${relativeBrowserDir}**/*[extension]`,
|
|
96
133
|
browserExtensions,
|
|
97
134
|
),
|
|
98
135
|
);
|