@msobiecki/eslint-config 9.9.0 → 9.11.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/CHANGELOG.md +14 -0
- package/eslint.config.js +34 -6
- package/package.json +1 -1
- package/rules/unicorn.js +9 -0
- package/utils/get-ts-config.js +40 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [9.11.0](https://github.com/msobiecki/eslint-config/compare/v9.10.0...v9.11.0) (2025-10-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* update eslint 9 ([725c4bb](https://github.com/msobiecki/eslint-config/commit/725c4bbe2857032ac705b25467e3ad6ce377d4b2))
|
|
7
|
+
|
|
8
|
+
# [9.10.0](https://github.com/msobiecki/eslint-config/compare/v9.9.0...v9.10.0) (2025-10-20)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* update eslint 9 ([9287c29](https://github.com/msobiecki/eslint-config/commit/9287c296c228ba6b4cb7d06f5a38cac221d8f5a0))
|
|
14
|
+
|
|
1
15
|
# [9.9.0](https://github.com/msobiecki/eslint-config/compare/v9.8.0...v9.9.0) (2025-10-20)
|
|
2
16
|
|
|
3
17
|
|
package/eslint.config.js
CHANGED
|
@@ -20,10 +20,11 @@ import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
|
|
|
20
20
|
import importxPlugin from "eslint-plugin-import-x";
|
|
21
21
|
import storybookPlugin from "eslint-plugin-storybook";
|
|
22
22
|
|
|
23
|
-
import getTsConfig from "./utils/get-ts-config.js";
|
|
23
|
+
import { getTsConfig, getBaseDirectory } from "./utils/get-ts-config.js";
|
|
24
24
|
|
|
25
|
-
import
|
|
25
|
+
import baseRules from "./rules/base.js";
|
|
26
26
|
import nodeRules from "./rules/node.js";
|
|
27
|
+
import unicornRules from "./rules/unicorn.js";
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Base / best-practice preset
|
|
@@ -35,7 +36,7 @@ export const basePreset = [
|
|
|
35
36
|
rules: {
|
|
36
37
|
...eslint.configs.recommended.rules,
|
|
37
38
|
// Custom best-practice rules
|
|
38
|
-
...
|
|
39
|
+
...baseRules,
|
|
39
40
|
},
|
|
40
41
|
},
|
|
41
42
|
{
|
|
@@ -44,7 +45,11 @@ export const basePreset = [
|
|
|
44
45
|
languageOptions: {
|
|
45
46
|
sourceType: "module",
|
|
46
47
|
parser: tseslint.parser,
|
|
47
|
-
parserOptions: {
|
|
48
|
+
parserOptions: {
|
|
49
|
+
project: getTsConfig(),
|
|
50
|
+
tsconfigRootDir: getBaseDirectory(),
|
|
51
|
+
ecmaFeatures: { jsx: true },
|
|
52
|
+
},
|
|
48
53
|
},
|
|
49
54
|
plugins: { "@typescript-eslint": tseslint.plugin },
|
|
50
55
|
rules: {
|
|
@@ -79,7 +84,22 @@ export const bestPracticePreset = [
|
|
|
79
84
|
...unicornPlugin.configs?.recommended?.rules,
|
|
80
85
|
...prettierPlugin.configs?.recommended?.rules,
|
|
81
86
|
|
|
82
|
-
|
|
87
|
+
...unicornRules,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "Filename Cases for JSX/TSX",
|
|
92
|
+
files: ["**/*.{jsx,tsx}"],
|
|
93
|
+
rules: {
|
|
94
|
+
"unicorn/filename-case": [
|
|
95
|
+
"error",
|
|
96
|
+
{
|
|
97
|
+
cases: {
|
|
98
|
+
camelCase: true,
|
|
99
|
+
pascalCase: true,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
],
|
|
83
103
|
},
|
|
84
104
|
},
|
|
85
105
|
];
|
|
@@ -98,6 +118,9 @@ export const reactPreset = [
|
|
|
98
118
|
},
|
|
99
119
|
languageOptions: {
|
|
100
120
|
parserOptions: { ecmaFeatures: { jsx: true } },
|
|
121
|
+
globals: {
|
|
122
|
+
...globals.browser,
|
|
123
|
+
},
|
|
101
124
|
},
|
|
102
125
|
rules: {
|
|
103
126
|
...reactBasePlugin.configs?.flat?.recommended?.rules,
|
|
@@ -234,4 +257,9 @@ export const storybookPreset = [
|
|
|
234
257
|
},
|
|
235
258
|
];
|
|
236
259
|
|
|
237
|
-
export default [
|
|
260
|
+
export default [
|
|
261
|
+
...basePreset,
|
|
262
|
+
...bestPracticePreset,
|
|
263
|
+
...nodePreset,
|
|
264
|
+
...importPreset,
|
|
265
|
+
];
|
package/package.json
CHANGED
package/rules/unicorn.js
ADDED
package/utils/get-ts-config.js
CHANGED
|
@@ -2,17 +2,49 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Get
|
|
6
|
-
* @returns {string
|
|
5
|
+
* Get the base directory for the project
|
|
6
|
+
* @returns {string} The base directory path
|
|
7
|
+
*/
|
|
8
|
+
export function getBaseDirectory() {
|
|
9
|
+
return process.cwd();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A safe wrapper for fs.existsSync() that only allows
|
|
14
|
+
* checking for files within your current workspace root.
|
|
15
|
+
*
|
|
16
|
+
* This prevents accidental non-literal or user-injected paths,
|
|
17
|
+
* while keeping eslint-plugin-security happy.
|
|
18
|
+
* @param {string} relativePath - The relative path to check
|
|
19
|
+
* @param {string} [baseDirection=process.cwd()] - The base directory to resolve from
|
|
20
|
+
* @returns {boolean} Whether the file exists
|
|
7
21
|
*/
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
22
|
+
export function safeExistsSync(
|
|
23
|
+
relativePath,
|
|
24
|
+
baseDirection = getBaseDirectory(),
|
|
25
|
+
) {
|
|
26
|
+
const fullPath = path.resolve(baseDirection, relativePath);
|
|
27
|
+
const normalizedBase = path.resolve(baseDirection);
|
|
28
|
+
|
|
29
|
+
if (!fullPath.startsWith(normalizedBase)) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Blocked attempt to access outside base directory: ${relativePath}`,
|
|
32
|
+
);
|
|
11
33
|
}
|
|
12
34
|
|
|
13
|
-
|
|
14
|
-
|
|
35
|
+
return fs.existsSync(fullPath);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get tsconfig path if exists
|
|
40
|
+
* @returns {string|undefined} The path to tsconfig.json or undefined if not found
|
|
41
|
+
*/
|
|
42
|
+
export function getTsConfig() {
|
|
43
|
+
const baseDirection = getBaseDirectory();
|
|
44
|
+
|
|
45
|
+
if (safeExistsSync("tsconfig.json", baseDirection)) {
|
|
46
|
+
return path.resolve(baseDirection, "tsconfig.json");
|
|
15
47
|
}
|
|
16
48
|
|
|
17
|
-
return;
|
|
49
|
+
return undefined;
|
|
18
50
|
}
|