@darksheep/eslint 7.0.4 โ 8.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/CHANGELOG.md +28 -0
- package/package.json +13 -13
- package/src/configs/eslint-recommended.js +26 -5
- package/src/plugins/jsdoc.js +8 -1
- package/src/plugins/style.js +21 -4
- package/src/plugins/unused-imports.js +2 -8
- package/src/utilities/filesystem.js +43 -10
- package/src/utilities/package.js +6 -5
- package/types/src/configs/eslint-recommended.d.ts +5 -2
- package/types/src/utilities/filesystem.d.ts +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [8.0.0](https://github.com/DarkSheepSoftware/eslint/compare/v7.0.4...v8.0.0) (2025-07-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### โ BREAKING CHANGES
|
|
7
|
+
|
|
8
|
+
* **pkg:** update dependency @stylistic/eslint-plugin to v5 ([#937](https://github.com/DarkSheepSoftware/eslint/issues/937))
|
|
9
|
+
|
|
10
|
+
### ๐ฆ Dependencies
|
|
11
|
+
|
|
12
|
+
* **pkg:** update dependency @eslint/compat to v1.3.1 ([#943](https://github.com/DarkSheepSoftware/eslint/issues/943)) ([3ed5836](https://github.com/DarkSheepSoftware/eslint/commit/3ed5836c91757adddd97e13caa022275a6b80aef))
|
|
13
|
+
* **pkg:** update dependency @stylistic/eslint-plugin to v5 ([#937](https://github.com/DarkSheepSoftware/eslint/issues/937)) ([f6b7cf3](https://github.com/DarkSheepSoftware/eslint/commit/f6b7cf3308acae3bc2bfa25de72da854afa2fb00))
|
|
14
|
+
* **pkg:** update dependency editorconfig to v3.0.1 ([#954](https://github.com/DarkSheepSoftware/eslint/issues/954)) ([5f7a87d](https://github.com/DarkSheepSoftware/eslint/commit/5f7a87dc7a8d3baacb7bfce3bf5836427fcb042d))
|
|
15
|
+
* **pkg:** update dependency eslint-plugin-jsdoc to v51.2.3 ([#938](https://github.com/DarkSheepSoftware/eslint/issues/938)) ([6cbc878](https://github.com/DarkSheepSoftware/eslint/commit/6cbc87875c4c32bcb80dec76e5b48baac2001159))
|
|
16
|
+
* **pkg:** update dependency eslint-plugin-jsdoc to v51.3.1 ([#946](https://github.com/DarkSheepSoftware/eslint/issues/946)) ([949c67b](https://github.com/DarkSheepSoftware/eslint/commit/949c67b529383140dde4b8173d9a8a85bfe18495))
|
|
17
|
+
* **pkg:** update dependency eslint-plugin-jsdoc to v51.4.1 ([#952](https://github.com/DarkSheepSoftware/eslint/issues/952)) ([b566232](https://github.com/DarkSheepSoftware/eslint/commit/b56623212f3f8d0c6b2bb77e2e9168e991ba8a51))
|
|
18
|
+
* **pkg:** update dependency eslint-plugin-n to v17.21.0 ([#953](https://github.com/DarkSheepSoftware/eslint/issues/953)) ([a2b6518](https://github.com/DarkSheepSoftware/eslint/commit/a2b6518c60eadbd3b7cc91e00c97796da254f4db))
|
|
19
|
+
* **pkg:** update dependency eslint-plugin-package-json to v0.42.0 ([#939](https://github.com/DarkSheepSoftware/eslint/issues/939)) ([c7e1459](https://github.com/DarkSheepSoftware/eslint/commit/c7e145933318e8758e334f666eb0ba325f88dbd5))
|
|
20
|
+
* **pkg:** update dependency eslint-plugin-package-json to v0.45.1 ([#949](https://github.com/DarkSheepSoftware/eslint/issues/949)) ([ab071a3](https://github.com/DarkSheepSoftware/eslint/commit/ab071a312e971e9cbd5aca69e1159bb60f2957a1))
|
|
21
|
+
* **pkg:** update eslint monorepo to v9.30.0 ([#944](https://github.com/DarkSheepSoftware/eslint/issues/944)) ([c82ce1d](https://github.com/DarkSheepSoftware/eslint/commit/c82ce1d510a3ac0784c85302d00411cf369cc6dd))
|
|
22
|
+
* **pkg:** update eslint monorepo to v9.31.0 ([#950](https://github.com/DarkSheepSoftware/eslint/issues/950)) ([196315b](https://github.com/DarkSheepSoftware/eslint/commit/196315bc9343a405d3deb0024af7ae4e40acbb2a))
|
|
23
|
+
* **pkg:** update typescript-eslint monorepo to v8.35.0 ([#940](https://github.com/DarkSheepSoftware/eslint/issues/940)) ([c84b7ca](https://github.com/DarkSheepSoftware/eslint/commit/c84b7caa6cd4e4db1c248a5b18952a4d177e6a82))
|
|
24
|
+
* **pkg:** update typescript-eslint monorepo to v8.37.0 ([#948](https://github.com/DarkSheepSoftware/eslint/issues/948)) ([fe66757](https://github.com/DarkSheepSoftware/eslint/commit/fe667578e323520bdc46970c44fe2a3f54a8eb18))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### ๐งน Chores
|
|
28
|
+
|
|
29
|
+
* handle being passed a file or a directory in listParents ([#955](https://github.com/DarkSheepSoftware/eslint/issues/955)) ([6dd86ec](https://github.com/DarkSheepSoftware/eslint/commit/6dd86ec2389799eacbe65b5f33bfd698570cc7ab))
|
|
30
|
+
|
|
3
31
|
## [7.0.4](https://github.com/DarkSheepSoftware/eslint/compare/v7.0.3...v7.0.4) (2025-06-23)
|
|
4
32
|
|
|
5
33
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darksheep/eslint",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/DarkSheepSoftware/eslint"
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@darksheep/environment": "3.1.0",
|
|
26
26
|
"@eslint-community/eslint-plugin-eslint-comments": "4.5.0",
|
|
27
|
-
"@eslint/compat": "1.3.
|
|
28
|
-
"@eslint/js": "9.
|
|
29
|
-
"@stylistic/eslint-plugin": "
|
|
30
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
31
|
-
"@typescript-eslint/parser": "8.
|
|
32
|
-
"editorconfig": "3.0.
|
|
33
|
-
"eslint-plugin-jsdoc": "51.
|
|
27
|
+
"@eslint/compat": "1.3.1",
|
|
28
|
+
"@eslint/js": "9.31.0",
|
|
29
|
+
"@stylistic/eslint-plugin": "5.2.0",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "8.37.0",
|
|
31
|
+
"@typescript-eslint/parser": "8.37.0",
|
|
32
|
+
"editorconfig": "3.0.1",
|
|
33
|
+
"eslint-plugin-jsdoc": "51.4.1",
|
|
34
34
|
"eslint-plugin-jsonc": "2.20.1",
|
|
35
|
-
"eslint-plugin-n": "17.
|
|
36
|
-
"eslint-plugin-package-json": "0.
|
|
35
|
+
"eslint-plugin-n": "17.21.0",
|
|
36
|
+
"eslint-plugin-package-json": "0.45.1",
|
|
37
37
|
"eslint-plugin-perfectionist": "4.15.0",
|
|
38
38
|
"eslint-plugin-promise": "7.2.1",
|
|
39
39
|
"eslint-plugin-react": "7.37.5",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@darksheep/eslint-formatter-github": "2.1.0",
|
|
51
|
-
"@types/node": "~22.
|
|
52
|
-
"eslint": "~9.
|
|
51
|
+
"@types/node": "~22.16.0",
|
|
52
|
+
"eslint": "~9.31.0",
|
|
53
53
|
"type-fest": "~4.41.0",
|
|
54
54
|
"typescript": "~5.8.0"
|
|
55
55
|
},
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"node": "^20 || ^22"
|
|
67
67
|
},
|
|
68
68
|
"volta": {
|
|
69
|
-
"node": "22.
|
|
69
|
+
"node": "22.17.1",
|
|
70
70
|
"yarn": "4.9.2"
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -1,12 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import { Linter } from 'eslint'
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
import js from '@eslint/js';
|
|
2
6
|
|
|
7
|
+
/** @type {Linter.RuleEntry} */
|
|
8
|
+
export const unusedConfig = [
|
|
9
|
+
'error', {
|
|
10
|
+
argsIgnorePattern: '^_',
|
|
11
|
+
varsIgnorePattern: '^_',
|
|
12
|
+
args: 'after-used',
|
|
13
|
+
vars: 'local',
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
|
|
3
17
|
/**
|
|
4
18
|
* Get recommended ESLint config.
|
|
5
|
-
* @returns {Promise<
|
|
19
|
+
* @returns {Promise<Linter.FlatConfig[]>}
|
|
6
20
|
*/
|
|
7
21
|
export async function createEslintRecommendsConfig() {
|
|
8
|
-
return [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
name: 'eslint/recomended',
|
|
25
|
+
...js.configs.recommended,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
rules: {
|
|
29
|
+
'no-unused-vars': unusedConfig,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
];
|
|
12
33
|
}
|
package/src/plugins/jsdoc.js
CHANGED
|
@@ -27,7 +27,14 @@ export async function createEslintJSDocConfig(root) {
|
|
|
27
27
|
'jsdoc/check-alignment': 'warn',
|
|
28
28
|
'jsdoc/check-examples': 'off',
|
|
29
29
|
'jsdoc/check-indentation': 'off',
|
|
30
|
-
'jsdoc/check-line-alignment': [
|
|
30
|
+
'jsdoc/check-line-alignment': [
|
|
31
|
+
'error',
|
|
32
|
+
'never',
|
|
33
|
+
{
|
|
34
|
+
tags: [ 'param', 'arg', 'argument', 'property', 'prop', 'returns', 'return' ],
|
|
35
|
+
customSpacings: { postDelimiter: 1, postTag: 1, postType: 1, postName: 1 },
|
|
36
|
+
},
|
|
37
|
+
],
|
|
31
38
|
'jsdoc/check-param-names': 'warn',
|
|
32
39
|
'jsdoc/check-property-names': 'warn',
|
|
33
40
|
'jsdoc/check-syntax': 'error',
|
package/src/plugins/style.js
CHANGED
|
@@ -22,9 +22,8 @@ export function createEslintStyleConfig() {
|
|
|
22
22
|
'style/computed-property-spacing': [ 'error', 'never' ],
|
|
23
23
|
'style/curly-newline': [ 'error', { consistent: true } ],
|
|
24
24
|
'style/dot-location': [ 'error', 'property' ],
|
|
25
|
-
'style/func-call-spacing': [ 'error', 'never' ],
|
|
26
25
|
'style/function-call-argument-newline': [ 'error', 'consistent' ],
|
|
27
|
-
'style/function-call-spacing': 'error',
|
|
26
|
+
'style/function-call-spacing': [ 'error', 'never' ],
|
|
28
27
|
'style/function-paren-newline': [ 'error', 'consistent' ],
|
|
29
28
|
'style/generator-star-spacing': [ 'error', 'both' ],
|
|
30
29
|
'style/implicit-arrow-linebreak': [ 'error', 'beside' ],
|
|
@@ -75,11 +74,29 @@ export function createEslintStyleConfig() {
|
|
|
75
74
|
'style/object-curly-spacing': [ 'error', 'always' ],
|
|
76
75
|
'style/object-property-newline': [ 'error', { allowAllPropertiesOnSameLine: true } ],
|
|
77
76
|
'style/one-var-declaration-per-line': [ 'error', 'initializations' ],
|
|
78
|
-
'style/operator-linebreak': [
|
|
77
|
+
'style/operator-linebreak': [
|
|
78
|
+
'error',
|
|
79
|
+
'after',
|
|
80
|
+
{
|
|
81
|
+
overrides: {
|
|
82
|
+
'?': 'before',
|
|
83
|
+
':': 'before',
|
|
84
|
+
'|': 'before',
|
|
85
|
+
'&': 'before',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
],
|
|
79
89
|
'style/padded-blocks': [ 'error', 'never' ],
|
|
80
90
|
'style/padding-line-between-statements': 'off',
|
|
81
91
|
'style/quote-props': [ 'error', 'consistent-as-needed' ],
|
|
82
|
-
'style/quotes': [
|
|
92
|
+
'style/quotes': [
|
|
93
|
+
'error',
|
|
94
|
+
'single',
|
|
95
|
+
{
|
|
96
|
+
allowTemplateLiterals: 'always',
|
|
97
|
+
avoidEscape: true,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
83
100
|
'style/rest-spread-spacing': [ 'error', 'never' ],
|
|
84
101
|
'style/semi-spacing': 'error',
|
|
85
102
|
'style/semi-style': [ 'error', 'last' ],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import unused from 'eslint-plugin-unused-imports';
|
|
2
2
|
|
|
3
|
+
import { unusedConfig } from '../configs/eslint-recommended.js';
|
|
3
4
|
import {
|
|
4
5
|
getModuleFiles,
|
|
5
6
|
getTypescriptFiles,
|
|
@@ -24,14 +25,7 @@ export async function createEslintUnusedImportsConfig(root) {
|
|
|
24
25
|
'@typescript-eslint/no-unused-vars': 'off',
|
|
25
26
|
|
|
26
27
|
'unused-imports/no-unused-imports': 'error',
|
|
27
|
-
'unused-imports/no-unused-vars':
|
|
28
|
-
'error', {
|
|
29
|
-
argsIgnorePattern: '^_',
|
|
30
|
-
varsIgnorePattern: '^_',
|
|
31
|
-
args: 'after-used',
|
|
32
|
-
vars: 'local',
|
|
33
|
-
},
|
|
34
|
-
],
|
|
28
|
+
'unused-imports/no-unused-vars': unusedConfig,
|
|
35
29
|
},
|
|
36
30
|
},
|
|
37
31
|
];
|
|
@@ -1,19 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import { Stats } from 'node:fs'
|
|
3
|
+
*/
|
|
1
4
|
import { stat } from 'node:fs/promises';
|
|
2
5
|
import * as Path from 'node:path';
|
|
3
6
|
|
|
7
|
+
/** @type {Map<string, Promise<Stats>>} */
|
|
8
|
+
const cache = new Map();
|
|
9
|
+
|
|
4
10
|
/**
|
|
5
|
-
* @param {string} path - The absolute path to the file to
|
|
6
|
-
* @returns {Promise<
|
|
11
|
+
* @param {string} path - The absolute path to the file to stat.
|
|
12
|
+
* @returns {Promise<Stats | undefined>}
|
|
7
13
|
*/
|
|
8
|
-
|
|
14
|
+
async function safeStat(path) {
|
|
9
15
|
try {
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
const promise = cache.get(path) ?? stat(path);
|
|
17
|
+
cache.set(path, promise);
|
|
18
|
+
|
|
19
|
+
return await promise;
|
|
12
20
|
} catch {
|
|
13
|
-
return
|
|
21
|
+
// Supress the error and return undefined
|
|
22
|
+
// We dont care about permissions here
|
|
14
23
|
}
|
|
15
24
|
}
|
|
16
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @param {string} path - The absolute path to the file to check.
|
|
28
|
+
* @returns {Promise<boolean>}
|
|
29
|
+
*/
|
|
30
|
+
export async function isFile(path) {
|
|
31
|
+
const stat = await safeStat(path);
|
|
32
|
+
return stat?.isFile() ?? false;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @param {string} path - The absolute path to the file to check.
|
|
36
|
+
* @returns {Promise<boolean>}
|
|
37
|
+
*/
|
|
38
|
+
export async function isDirectory(path) {
|
|
39
|
+
const stat = await safeStat(path);
|
|
40
|
+
return stat?.isDirectory() ?? false;
|
|
41
|
+
}
|
|
42
|
+
|
|
17
43
|
/**
|
|
18
44
|
* Does {filePath} exist in {projectPath}.
|
|
19
45
|
* @param {string} [filePath] - The path of the file to check.
|
|
@@ -35,15 +61,19 @@ export function descendsFrom(filePath, projectPath) {
|
|
|
35
61
|
* Create a list of parent directories from {filepath} to {stopDirectory}.
|
|
36
62
|
* @param {string} filepath - The file to start from.
|
|
37
63
|
* @param {string} [stopDirectory] - The directory to stop at.
|
|
38
|
-
* @returns {string[]}
|
|
64
|
+
* @returns {Promise<string[]>}
|
|
39
65
|
*/
|
|
40
|
-
export function listParents(filepath, stopDirectory = '/') {
|
|
66
|
+
export async function listParents(filepath, stopDirectory = '/') {
|
|
41
67
|
// The file is not from within the stopDirectory
|
|
42
68
|
if (descendsFrom(filepath, stopDirectory) === false) {
|
|
43
69
|
return [];
|
|
44
70
|
}
|
|
45
71
|
|
|
46
72
|
const output = [];
|
|
73
|
+
if (await isDirectory(filepath)) {
|
|
74
|
+
output.push(filepath);
|
|
75
|
+
}
|
|
76
|
+
|
|
47
77
|
const end = Path.resolve(stopDirectory);
|
|
48
78
|
do {
|
|
49
79
|
filepath = Path.dirname(filepath);
|
|
@@ -63,7 +93,7 @@ export async function findInPaths(paths, filename) {
|
|
|
63
93
|
for (const directory of paths) {
|
|
64
94
|
const target = Path.join(directory, filename);
|
|
65
95
|
|
|
66
|
-
if (await
|
|
96
|
+
if (await isFile(target)) {
|
|
67
97
|
return target;
|
|
68
98
|
}
|
|
69
99
|
}
|
|
@@ -79,5 +109,8 @@ export async function findInPaths(paths, filename) {
|
|
|
79
109
|
* @returns {Promise<string|null>} Returns absolute path to the closest {filename} if found.
|
|
80
110
|
*/
|
|
81
111
|
export async function findUp(rootFilePath, filename, stopDirectory = Path.resolve('/')) {
|
|
82
|
-
return findInPaths(
|
|
112
|
+
return findInPaths(
|
|
113
|
+
await listParents(rootFilePath, stopDirectory),
|
|
114
|
+
filename,
|
|
115
|
+
);
|
|
83
116
|
}
|
package/src/utilities/package.js
CHANGED
|
@@ -14,11 +14,12 @@ const cache = new Map();
|
|
|
14
14
|
/**
|
|
15
15
|
* @param {string} rootPath - The root url.
|
|
16
16
|
* @param {string} packageName - The target package name.
|
|
17
|
-
* @returns {string[]}
|
|
17
|
+
* @returns {Promise<string[]>}
|
|
18
18
|
*/
|
|
19
|
-
function modulePaths(rootPath, packageName) {
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
async function modulePaths(rootPath, packageName) {
|
|
20
|
+
const parents = await listParents(`${rootPath}/eslint.config.js`);
|
|
21
|
+
|
|
22
|
+
return parents.map((path) => resolve(path, 'node_modules', packageName));
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -34,7 +35,7 @@ export async function getPackageJson(rootUrl, packageName) {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
const jsonPath = typeof packageName === 'string'
|
|
37
|
-
? await findInPaths(modulePaths(root, packageName), 'package.json')
|
|
38
|
+
? await findInPaths(await modulePaths(root, packageName), 'package.json')
|
|
38
39
|
: await findUp(root, 'package.json');
|
|
39
40
|
|
|
40
41
|
if (jsonPath == null) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Get recommended ESLint config.
|
|
3
|
-
* @returns {Promise<
|
|
3
|
+
* @returns {Promise<Linter.FlatConfig[]>}
|
|
4
4
|
*/
|
|
5
|
-
export function createEslintRecommendsConfig(): Promise<
|
|
5
|
+
export function createEslintRecommendsConfig(): Promise<Linter.FlatConfig[]>;
|
|
6
|
+
/** @type {Linter.RuleEntry} */
|
|
7
|
+
export const unusedConfig: Linter.RuleEntry;
|
|
8
|
+
import type { Linter } from 'eslint';
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
* @param {string} path - The absolute path to the file to check.
|
|
3
3
|
* @returns {Promise<boolean>}
|
|
4
4
|
*/
|
|
5
|
-
export function
|
|
5
|
+
export function isFile(path: string): Promise<boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* @param {string} path - The absolute path to the file to check.
|
|
8
|
+
* @returns {Promise<boolean>}
|
|
9
|
+
*/
|
|
10
|
+
export function isDirectory(path: string): Promise<boolean>;
|
|
6
11
|
/**
|
|
7
12
|
* Does {filePath} exist in {projectPath}.
|
|
8
13
|
* @param {string} [filePath] - The path of the file to check.
|
|
@@ -14,9 +19,9 @@ export function descendsFrom(filePath?: string, projectPath?: string): boolean;
|
|
|
14
19
|
* Create a list of parent directories from {filepath} to {stopDirectory}.
|
|
15
20
|
* @param {string} filepath - The file to start from.
|
|
16
21
|
* @param {string} [stopDirectory] - The directory to stop at.
|
|
17
|
-
* @returns {string[]}
|
|
22
|
+
* @returns {Promise<string[]>}
|
|
18
23
|
*/
|
|
19
|
-
export function listParents(filepath: string, stopDirectory?: string): string[]
|
|
24
|
+
export function listParents(filepath: string, stopDirectory?: string): Promise<string[]>;
|
|
20
25
|
/**
|
|
21
26
|
* Find the closest {filename} starting from {rootFilePath}.
|
|
22
27
|
* @param {string[]} paths - The paths to search in.
|