@darksheep/eslint 6.4.2 → 6.5.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 +52 -0
- package/package.json +12 -13
- package/src/configs/eslint-base.js +3 -3
- package/src/configs/eslint-complexity.js +2 -2
- package/src/configs/eslint-ignores.js +5 -5
- package/src/configs/eslint-recommended.js +2 -2
- package/src/configs/eslint-style.js +3 -3
- package/src/custom-logger/index.js +20 -11
- package/src/custom-rules/instance-of-array.js +4 -4
- package/src/custom-rules/loose-types.js +52 -52
- package/src/custom-rules/no-useless-expression.js +1 -1
- package/src/custom-rules/sequence-expression.js +1 -1
- package/src/index.js +14 -10
- package/src/plugins/eslint-comments.js +4 -4
- package/src/plugins/jsdoc.js +40 -12
- package/src/plugins/json.js +10 -2
- package/src/plugins/node.js +18 -24
- package/src/plugins/package-json.js +5 -9
- package/src/plugins/perfectionist.js +12 -3
- package/src/plugins/promise.js +6 -2
- package/src/plugins/react.js +3 -3
- package/src/plugins/regexp.js +96 -3
- package/src/plugins/sca.js +3 -3
- package/src/plugins/security.js +2 -2
- package/src/plugins/style.js +61 -208
- package/src/plugins/typescript.js +4 -4
- package/src/plugins/unicorn.js +142 -51
- package/src/plugins/unused-imports.js +3 -3
- package/src/plugins/yml.js +8 -2
- package/src/utilities/editorconfig.js +18 -18
- package/src/utilities/eslint-files.js +10 -10
- package/src/utilities/expand-glob.js +8 -8
- package/src/utilities/filesystem.js +16 -16
- package/src/utilities/package.js +5 -5
- package/types/eslint.config.d.ts +5 -1
- package/types/src/configs/eslint-base.d.ts +3 -3
- package/types/src/configs/eslint-complexity.d.ts +3 -3
- package/types/src/configs/eslint-ignores.d.ts +4 -4
- package/types/src/configs/eslint-recommended.d.ts +3 -3
- package/types/src/configs/eslint-style.d.ts +4 -4
- package/types/src/index.d.ts +3 -3
- package/types/src/plugins/eslint-comments.d.ts +3 -3
- package/types/src/plugins/jsdoc.d.ts +4 -4
- package/types/src/plugins/json.d.ts +3 -3
- package/types/src/plugins/node.d.ts +4 -4
- package/types/src/plugins/package-json.d.ts +3 -3
- package/types/src/plugins/perfectionist.d.ts +4 -4
- package/types/src/plugins/promise.d.ts +3 -3
- package/types/src/plugins/react.d.ts +4 -4
- package/types/src/plugins/regexp.d.ts +3 -3
- package/types/src/plugins/sca.d.ts +4 -4
- package/types/src/plugins/security.d.ts +3 -3
- package/types/src/plugins/style.d.ts +3 -3
- package/types/src/plugins/typescript.d.ts +4 -4
- package/types/src/plugins/unicorn.d.ts +4 -3
- package/types/src/plugins/unused-imports.d.ts +4 -4
- package/types/src/plugins/yml.d.ts +3 -3
- package/types/src/utilities/editorconfig.d.ts +10 -10
- package/types/src/utilities/eslint-files.d.ts +7 -7
- package/types/src/utilities/expand-glob.d.ts +1 -1
- package/types/src/utilities/filesystem.d.ts +16 -16
- package/types/src/utilities/package.d.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [6.5.0](https://github.com/DarkSheepSoftware/eslint/compare/v6.4.3...v6.5.0) (2024-10-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### 🌟 Features
|
|
7
|
+
|
|
8
|
+
* Add ability to use custom bullet point ([361542c](https://github.com/DarkSheepSoftware/eslint/commit/361542c04443bcfa046cfbc83c9c95513acd514a))
|
|
9
|
+
* Remove ts and eslint deprecations ([8680107](https://github.com/DarkSheepSoftware/eslint/commit/8680107bae5bc65288353be1ca149fe4a1bc6443))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### 🩹 Fixes
|
|
13
|
+
|
|
14
|
+
* Add missing rules from jsdoc plugin ([d402a53](https://github.com/DarkSheepSoftware/eslint/commit/d402a53ec8f37ce94fa1d36c63ce1babbfedc671))
|
|
15
|
+
* Add missing rules from json plugin ([7a53d3c](https://github.com/DarkSheepSoftware/eslint/commit/7a53d3c2ed9b75654bc558430a9cc1a856c3664b))
|
|
16
|
+
* Add missing rules from n plugin ([7b37d96](https://github.com/DarkSheepSoftware/eslint/commit/7b37d968aeb0a8c85025a7a2649216c6b270f120))
|
|
17
|
+
* Add missing rules from package-json plugin ([8c3de54](https://github.com/DarkSheepSoftware/eslint/commit/8c3de54eaba5cf69e3f4c6e562447f999b9793cf))
|
|
18
|
+
* Add missing rules from perfectionist plugin ([a6388de](https://github.com/DarkSheepSoftware/eslint/commit/a6388ded57d9b4261397f016e82b8f5f1060e497))
|
|
19
|
+
* Add missing rules from regexp plugin ([a2b4876](https://github.com/DarkSheepSoftware/eslint/commit/a2b487685b1a686aa35aa73a664d610b4b181a38))
|
|
20
|
+
* Add missing rules from style plugin ([9fbf9c6](https://github.com/DarkSheepSoftware/eslint/commit/9fbf9c654d4e866b0f2746fc350af42e1d8f7a57))
|
|
21
|
+
* Add missing rules from unicorn plugin ([0e56541](https://github.com/DarkSheepSoftware/eslint/commit/0e56541a56e78a9ec71f009e3f9f234a3c40c0f8))
|
|
22
|
+
* Add missing rules from yml plugin ([41032f7](https://github.com/DarkSheepSoftware/eslint/commit/41032f75959f903fedb690514996dbfc844280d3))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### 📦 Dependencies
|
|
26
|
+
|
|
27
|
+
* **pkg:** update dependency @stylistic/eslint-plugin to v2.9.0 ([#662](https://github.com/DarkSheepSoftware/eslint/issues/662)) ([4b85376](https://github.com/DarkSheepSoftware/eslint/commit/4b853768d356814f159f058abcb430e109737acc))
|
|
28
|
+
* **pkg:** update dependency eslint-plugin-jsdoc to v50.3.1 ([#657](https://github.com/DarkSheepSoftware/eslint/issues/657)) ([9389881](https://github.com/DarkSheepSoftware/eslint/commit/9389881cc56556449dbc873c6ac1225370f8f7c3))
|
|
29
|
+
* **pkg:** update dependency eslint-plugin-n to v17.11.0 ([#667](https://github.com/DarkSheepSoftware/eslint/issues/667)) ([234542e](https://github.com/DarkSheepSoftware/eslint/commit/234542e0e5b6df46ba67247b238360c135367f12))
|
|
30
|
+
* **pkg:** update dependency eslint-plugin-n to v17.11.1 ([#669](https://github.com/DarkSheepSoftware/eslint/issues/669)) ([63ef4a8](https://github.com/DarkSheepSoftware/eslint/commit/63ef4a877e4715be62c6511ae7f3ce1628c0e4e2))
|
|
31
|
+
* **pkg:** update dependency eslint-plugin-perfectionist to v3.8.0 ([#656](https://github.com/DarkSheepSoftware/eslint/issues/656)) ([bfa5b29](https://github.com/DarkSheepSoftware/eslint/commit/bfa5b29a3c925d4aa1a89ff1d0bb4dde7a6b56cc))
|
|
32
|
+
* **pkg:** update dependency eslint-plugin-react to v7.37.1 ([#659](https://github.com/DarkSheepSoftware/eslint/issues/659)) ([ccc0c22](https://github.com/DarkSheepSoftware/eslint/commit/ccc0c22389bbebb0e4a1ac54c5402305a80839ce))
|
|
33
|
+
* **pkg:** update dependency eslint-plugin-unicorn to v56 ([#660](https://github.com/DarkSheepSoftware/eslint/issues/660)) ([98e84c6](https://github.com/DarkSheepSoftware/eslint/commit/98e84c6eacffb371ef82898e94a6ba352c9baccc))
|
|
34
|
+
* **pkg:** update eslint monorepo to v9.12.0 ([#661](https://github.com/DarkSheepSoftware/eslint/issues/661)) ([936ddbe](https://github.com/DarkSheepSoftware/eslint/commit/936ddbe85644c296b9edc0db0f4bc2de9297d263))
|
|
35
|
+
* **pkg:** update typescript-eslint monorepo to v8.8.0 ([#655](https://github.com/DarkSheepSoftware/eslint/issues/655)) ([ce22824](https://github.com/DarkSheepSoftware/eslint/commit/ce2282449ca77e228388d2f9b4e6bafbdf0cee18))
|
|
36
|
+
* **pkg:** update typescript-eslint monorepo to v8.8.1 ([#664](https://github.com/DarkSheepSoftware/eslint/issues/664)) ([abe4a28](https://github.com/DarkSheepSoftware/eslint/commit/abe4a285b988c6930c8295a5a230fd4af3a01bdc))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### 🧹 Chores
|
|
40
|
+
|
|
41
|
+
* Fix comment spacing ([8af91a8](https://github.com/DarkSheepSoftware/eslint/commit/8af91a89747657944be9dadd2b865c86ba74500a))
|
|
42
|
+
|
|
43
|
+
## [6.4.3](https://github.com/DarkSheepSoftware/eslint/compare/v6.4.2...v6.4.3) (2024-09-30)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### 📦 Dependencies
|
|
47
|
+
|
|
48
|
+
* **pkg:** update dependency eslint-plugin-jsdoc to v50.3.0 ([#652](https://github.com/DarkSheepSoftware/eslint/issues/652)) ([c809a93](https://github.com/DarkSheepSoftware/eslint/commit/c809a9324cd88bc89fdc1884354ddfc2cb44bff2))
|
|
49
|
+
* **pkg:** update dependency eslint-plugin-perfectionist to v3.7.0 ([#647](https://github.com/DarkSheepSoftware/eslint/issues/647)) ([a696685](https://github.com/DarkSheepSoftware/eslint/commit/a6966857ff4d2bef80a195de4d0f6f859cece432))
|
|
50
|
+
* **pkg:** update dependency eslint-plugin-react to v7.37.0 ([#653](https://github.com/DarkSheepSoftware/eslint/issues/653)) ([713dab2](https://github.com/DarkSheepSoftware/eslint/commit/713dab2cc601ba86660c8f4ca499e5325eea7d26))
|
|
51
|
+
* **pkg:** update eslint monorepo to v9.11.0 ([#644](https://github.com/DarkSheepSoftware/eslint/issues/644)) ([bf4acbb](https://github.com/DarkSheepSoftware/eslint/commit/bf4acbb23059fa99decaf9c08dc390d933170ae8))
|
|
52
|
+
* **pkg:** update eslint monorepo to v9.11.1 ([#650](https://github.com/DarkSheepSoftware/eslint/issues/650)) ([9de8ccf](https://github.com/DarkSheepSoftware/eslint/commit/9de8ccf08388320b27a4e0418d731586362ce6f5))
|
|
53
|
+
* **pkg:** update typescript-eslint monorepo to v8.7.0 ([#648](https://github.com/DarkSheepSoftware/eslint/issues/648)) ([80acfae](https://github.com/DarkSheepSoftware/eslint/commit/80acfae97e9ed9e434451375098e1fd02927f6cf))
|
|
54
|
+
|
|
3
55
|
## [6.4.2](https://github.com/DarkSheepSoftware/eslint/compare/v6.4.1...v6.4.2) (2024-09-19)
|
|
4
56
|
|
|
5
57
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darksheep/eslint",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/DarkSheepSoftware/eslint"
|
|
@@ -22,24 +22,23 @@
|
|
|
22
22
|
"prepack": "tsc"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"@darksheep/environment": "3.0.9",
|
|
25
26
|
"@eslint-community/eslint-plugin-eslint-comments": "4.4.0",
|
|
26
|
-
"@eslint/js": "9.
|
|
27
|
-
"@stylistic/eslint-plugin": "2.
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@typescript-eslint/eslint-plugin": "8.6.0",
|
|
31
|
-
"@typescript-eslint/parser": "8.6.0",
|
|
27
|
+
"@eslint/js": "9.12.0",
|
|
28
|
+
"@stylistic/eslint-plugin": "2.9.0",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "8.8.1",
|
|
30
|
+
"@typescript-eslint/parser": "8.8.1",
|
|
32
31
|
"editorconfig": "2.0.0",
|
|
33
|
-
"eslint-plugin-jsdoc": "50.
|
|
32
|
+
"eslint-plugin-jsdoc": "50.3.1",
|
|
34
33
|
"eslint-plugin-jsonc": "2.16.0",
|
|
35
|
-
"eslint-plugin-n": "17.
|
|
34
|
+
"eslint-plugin-n": "17.11.1",
|
|
36
35
|
"eslint-plugin-package-json": "0.15.3",
|
|
37
|
-
"eslint-plugin-perfectionist": "3.
|
|
36
|
+
"eslint-plugin-perfectionist": "3.8.0",
|
|
38
37
|
"eslint-plugin-promise": "7.1.0",
|
|
39
|
-
"eslint-plugin-react": "7.
|
|
38
|
+
"eslint-plugin-react": "7.37.1",
|
|
40
39
|
"eslint-plugin-regexp": "2.6.0",
|
|
41
40
|
"eslint-plugin-security": "3.0.1",
|
|
42
|
-
"eslint-plugin-unicorn": "
|
|
41
|
+
"eslint-plugin-unicorn": "56.0.0",
|
|
43
42
|
"eslint-plugin-unused-imports": "4.1.4",
|
|
44
43
|
"eslint-plugin-yml": "1.14.0",
|
|
45
44
|
"jsonc-eslint-parser": "2.4.0",
|
|
@@ -48,7 +47,7 @@
|
|
|
48
47
|
"devDependencies": {
|
|
49
48
|
"@darksheep/eslint-formatter-github": "2.0.1",
|
|
50
49
|
"@types/node": "~20.16.0",
|
|
51
|
-
"eslint": "~9.
|
|
50
|
+
"eslint": "~9.12.0",
|
|
52
51
|
"type-fest": "~4.26.0",
|
|
53
52
|
"typescript": "~5.6.0"
|
|
54
53
|
},
|
|
@@ -91,7 +91,7 @@ const rules = {
|
|
|
91
91
|
'consistent-this': [ 'error', 'that' ],
|
|
92
92
|
'no-array-constructor': 'error',
|
|
93
93
|
'no-lonely-if': 'error',
|
|
94
|
-
'no-negated-condition': '
|
|
94
|
+
'no-negated-condition': 'off', // unicorn/no-negated-condition
|
|
95
95
|
'no-object-constructor': 'error',
|
|
96
96
|
'no-nested-ternary': 'warn',
|
|
97
97
|
'no-unneeded-ternary': 'warn',
|
|
@@ -108,8 +108,8 @@ const rules = {
|
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
|
-
* Get the ESLint base config
|
|
112
|
-
* @returns {Promise<import('eslint').Linter.
|
|
111
|
+
* Get the ESLint base config.
|
|
112
|
+
* @returns {Promise<import('eslint').Linter.Config[]>}
|
|
113
113
|
*/
|
|
114
114
|
export async function createEslintBaseConfig() {
|
|
115
115
|
return [ {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Get the ESLint config for complexity checks
|
|
3
|
-
* @returns {import('eslint').Linter.
|
|
2
|
+
* Get the ESLint config for complexity checks.
|
|
3
|
+
* @returns {import('eslint').Linter.Config[]}
|
|
4
4
|
*/
|
|
5
5
|
export function createEslintComplexityConfig() {
|
|
6
6
|
return [ {
|
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
5
5
|
import { findUp } from '../utilities/filesystem.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @param {import('node:url').URL} root
|
|
8
|
+
* @param {import('node:url').URL} root - Root url.
|
|
9
9
|
* @returns {Promise<string[]>}
|
|
10
10
|
*/
|
|
11
11
|
async function getGitignore(root) {
|
|
@@ -17,7 +17,7 @@ async function getGitignore(root) {
|
|
|
17
17
|
const raw = await fs.readFile(path, 'utf8');
|
|
18
18
|
|
|
19
19
|
return raw
|
|
20
|
-
.split(/\r?\n|\r/)
|
|
20
|
+
.split(/\r?\n|\r/u)
|
|
21
21
|
.filter(Boolean);
|
|
22
22
|
} catch (error) {
|
|
23
23
|
if (/** @type {NodeJS.ErrnoException} */ (error).code === 'ENOENT') {
|
|
@@ -29,9 +29,9 @@ async function getGitignore(root) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* Get basic ESLint ignores config
|
|
33
|
-
* @param {import('node:url').URL} root
|
|
34
|
-
* @returns {Promise<import('eslint').Linter.
|
|
32
|
+
* Get basic ESLint ignores config.
|
|
33
|
+
* @param {import('node:url').URL} root - Root url.
|
|
34
|
+
* @returns {Promise<import('eslint').Linter.Config[]>}
|
|
35
35
|
*/
|
|
36
36
|
export async function createEslintIgnoresConfig(root) {
|
|
37
37
|
const ignores = await getGitignore(root);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import js from '@eslint/js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Get recommended ESLint config
|
|
5
|
-
* @returns {Promise<import('eslint').Linter.
|
|
4
|
+
* Get recommended ESLint config.
|
|
5
|
+
* @returns {Promise<import('eslint').Linter.Config[]>}
|
|
6
6
|
*/
|
|
7
7
|
export async function createEslintRecommendsConfig() {
|
|
8
8
|
return [ {
|
|
@@ -11,9 +11,9 @@ const rules = {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Get basic ESLint style config
|
|
15
|
-
* @param {import('node:url').URL} root
|
|
16
|
-
* @returns {Promise<import('eslint').Linter.
|
|
14
|
+
* Get basic ESLint style config.
|
|
15
|
+
* @param {import('node:url').URL} root - Root url.
|
|
16
|
+
* @returns {Promise<import('eslint').Linter.Config[]>}
|
|
17
17
|
*/
|
|
18
18
|
export async function createStyleConfig(root) {
|
|
19
19
|
return [
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { relative } from 'node:path';
|
|
2
2
|
|
|
3
|
+
import { getEnvString } from '@darksheep/environment';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
|
-
* @param {import('eslint').Linter.LintMessage[][]} files
|
|
6
|
+
* @param {import('eslint').Linter.LintMessage[][]} files - Some messages.
|
|
5
7
|
* @returns {number}
|
|
6
8
|
*/
|
|
7
9
|
function getSeverity(files) {
|
|
@@ -25,11 +27,15 @@ function getSeverity(files) {
|
|
|
25
27
|
return severity;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
/** @type {(
|
|
29
|
-
const toBoolean = (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
/** @type {(name: string) => boolean} */
|
|
31
|
+
const toBoolean = (name) => {
|
|
32
|
+
const value = getEnvString(name);
|
|
33
|
+
if (value == null) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return value !== 'false';
|
|
38
|
+
};
|
|
33
39
|
|
|
34
40
|
function isInEditor() {
|
|
35
41
|
return (
|
|
@@ -42,11 +48,12 @@ function isInEditor() {
|
|
|
42
48
|
);
|
|
43
49
|
}
|
|
44
50
|
|
|
51
|
+
const point = getEnvString('ESLINT_LOG_POINT') ?? '~';
|
|
45
52
|
const icons = [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
`\u001B[32m${point}\u001B[0m`, // circle - green
|
|
54
|
+
`\u001B[34m${point}\u001B[0m`, // circle - blue
|
|
55
|
+
`\u001B[33m${point}\u001B[0m`, // circle - yellow
|
|
56
|
+
`\u001B[31m${point}\u001B[0m`, // circle - red
|
|
50
57
|
];
|
|
51
58
|
|
|
52
59
|
/** @type {Set<string>} */
|
|
@@ -65,7 +72,9 @@ export default {
|
|
|
65
72
|
return messages.flat();
|
|
66
73
|
}
|
|
67
74
|
|
|
68
|
-
|
|
75
|
+
if (files.size > 0) {
|
|
76
|
+
process.stdout.write(files.has(filename) ? '\r' : '\n');
|
|
77
|
+
}
|
|
69
78
|
files.add(filename);
|
|
70
79
|
|
|
71
80
|
const icon = icons[getSeverity(messages) + 1];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {import('eslint').Rule.RuleContext} context ESLint rule context
|
|
2
|
+
* @param {import('eslint').Rule.RuleContext} context - ESLint rule context.
|
|
3
3
|
* @returns {import('eslint').Rule.RuleListener}
|
|
4
4
|
*/
|
|
5
5
|
const preferInstance = (context) => ({
|
|
6
6
|
/**
|
|
7
|
-
* @param {import('eslint').Rule.Node} node The AST function node
|
|
7
|
+
* @param {import('eslint').Rule.Node} node - The AST function node.
|
|
8
8
|
* @returns {void}
|
|
9
9
|
*/
|
|
10
10
|
'CallExpression[callee.object.name = "Array"][callee.property.name = "isArray"]': (node) => {
|
|
@@ -27,12 +27,12 @@ const preferInstance = (context) => ({
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* @param {import('eslint').Rule.RuleContext} context ESLint rule context
|
|
30
|
+
* @param {import('eslint').Rule.RuleContext} context - ESLint rule context.
|
|
31
31
|
* @returns {import('eslint').Rule.RuleListener}
|
|
32
32
|
*/
|
|
33
33
|
const preferIsArray = (context) => ({
|
|
34
34
|
/**
|
|
35
|
-
* @param {import('eslint').Rule.Node} node The AST function node
|
|
35
|
+
* @param {import('eslint').Rule.Node} node - The AST function node.
|
|
36
36
|
* @returns {void}
|
|
37
37
|
*/
|
|
38
38
|
'BinaryExpression[operator="instanceof"][right.type="Identifier"][right.name="Array"]': (node) => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {string} optionName
|
|
3
|
-
* @param {import('eslint').Rule.RuleContext} context ESLint rule context
|
|
4
|
-
* @param {string} message
|
|
2
|
+
* @param {string} optionName - Name of the property option.
|
|
3
|
+
* @param {import('eslint').Rule.RuleContext} context - ESLint rule context.
|
|
4
|
+
* @param {string} message - Error message on report.
|
|
5
5
|
* @returns {(node: import('eslint').Rule.Node) => void}
|
|
6
6
|
*/
|
|
7
7
|
function createReporter(optionName, context, message) {
|
|
8
8
|
const [ options ] = context.options;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* @param {import('eslint').Rule.Node} node The AST function node
|
|
11
|
+
* @param {import('eslint').Rule.Node} node - The AST function node.
|
|
12
12
|
* @returns {void}
|
|
13
13
|
*/
|
|
14
14
|
function validateNode(node) {
|
|
@@ -52,9 +52,9 @@ const rule = {
|
|
|
52
52
|
create: function (context) {
|
|
53
53
|
return {
|
|
54
54
|
/*
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
* var b = a ? 'hello' : 'there';
|
|
56
|
+
* if (a) return 'hello';
|
|
57
|
+
*/
|
|
58
58
|
'Identifier.test': createReporter(
|
|
59
59
|
'allowConditionalExpressionIdentifier',
|
|
60
60
|
context,
|
|
@@ -62,9 +62,9 @@ const rule = {
|
|
|
62
62
|
),
|
|
63
63
|
|
|
64
64
|
/*
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
* var b = object.key ? 'hello' : 'there';
|
|
66
|
+
* if (object.key) return 'hello';
|
|
67
|
+
*/
|
|
68
68
|
'MemberExpression.test': createReporter(
|
|
69
69
|
'allowConditionalExpressionMemberExpression',
|
|
70
70
|
context,
|
|
@@ -72,9 +72,9 @@ const rule = {
|
|
|
72
72
|
),
|
|
73
73
|
|
|
74
74
|
/*
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
* var b = object?.key ? 'hello' : 'there';
|
|
76
|
+
* if (object?.key) return 'hello';
|
|
77
|
+
*/
|
|
78
78
|
'ChainExpression.test': createReporter(
|
|
79
79
|
'allowConditionalExpressionChainExpression',
|
|
80
80
|
context,
|
|
@@ -82,12 +82,12 @@ const rule = {
|
|
|
82
82
|
),
|
|
83
83
|
|
|
84
84
|
/*
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
* var b = a() ? 'hello' : 'there';
|
|
86
|
+
* if (a()) return 'hello';
|
|
87
|
+
*
|
|
88
|
+
* var b = object.key() ? 'hello' : 'there';
|
|
89
|
+
* if (object.key()) return 'hello';
|
|
90
|
+
*/
|
|
91
91
|
'CallExpression.test': createReporter(
|
|
92
92
|
'allowConditionalExpressionCallExpression',
|
|
93
93
|
context,
|
|
@@ -95,9 +95,9 @@ const rule = {
|
|
|
95
95
|
),
|
|
96
96
|
|
|
97
97
|
/*
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
* one === 1 && two
|
|
99
|
+
* one === 1 || two
|
|
100
|
+
*/
|
|
101
101
|
'LogicalExpression[operator="&&"] > Identifier.right, LogicalExpression[operator="||"] > Identifier.right': createReporter(
|
|
102
102
|
'allowLogicalExpressionIdentifier',
|
|
103
103
|
context,
|
|
@@ -105,12 +105,12 @@ const rule = {
|
|
|
105
105
|
),
|
|
106
106
|
|
|
107
107
|
/*
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
* one === 1 && two()
|
|
109
|
+
* one === 1 || two()
|
|
110
|
+
*
|
|
111
|
+
* one === 1 && object.two()
|
|
112
|
+
* one === 1 || object.two()
|
|
113
|
+
*/
|
|
114
114
|
'LogicalExpression[operator="&&"] > CallExpression.right, LogicalExpression[operator="||"] > CallExpression.right': createReporter(
|
|
115
115
|
'allowLogicalExpressionCallExpression',
|
|
116
116
|
context,
|
|
@@ -118,9 +118,9 @@ const rule = {
|
|
|
118
118
|
),
|
|
119
119
|
|
|
120
120
|
/*
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
* one === 1 && object.two
|
|
122
|
+
* one === 1 || object.two
|
|
123
|
+
*/
|
|
124
124
|
'LogicalExpression[operator="&&"] > MemberExpression.right, LogicalExpression[operator="||"] > MemberExpression.right': createReporter(
|
|
125
125
|
'allowLogicalExpressionMemberExpression',
|
|
126
126
|
context,
|
|
@@ -128,9 +128,9 @@ const rule = {
|
|
|
128
128
|
),
|
|
129
129
|
|
|
130
130
|
/*
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
* one === 1 && object?.two
|
|
132
|
+
* one === 1 || object?.two
|
|
133
|
+
*/
|
|
134
134
|
'LogicalExpression[operator="&&"] > ChainExpression.right, LogicalExpression[operator="||"] > ChainExpression.right': createReporter(
|
|
135
135
|
'allowLogicalExpressionChainExpression',
|
|
136
136
|
context,
|
|
@@ -138,9 +138,9 @@ const rule = {
|
|
|
138
138
|
),
|
|
139
139
|
|
|
140
140
|
/*
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
* one && two === 2
|
|
142
|
+
* one || two === 2
|
|
143
|
+
*/
|
|
144
144
|
'LogicalExpression[operator="&&"] > Identifier.left, LogicalExpression[operator="||"] > Identifier.left': createReporter(
|
|
145
145
|
'allowLogicalExpressionIdentifier',
|
|
146
146
|
context,
|
|
@@ -148,15 +148,15 @@ const rule = {
|
|
|
148
148
|
),
|
|
149
149
|
|
|
150
150
|
/*
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
151
|
+
* one() && two === 2
|
|
152
|
+
* one() || two === 2
|
|
153
|
+
*
|
|
154
|
+
* object.one() && two === 2
|
|
155
|
+
* object.one() || two === 2
|
|
156
|
+
*
|
|
157
|
+
* object?.one() && two === 2
|
|
158
|
+
* object?.one() || two === 2
|
|
159
|
+
*/
|
|
160
160
|
'LogicalExpression[operator="&&"] > CallExpression.left, LogicalExpression[operator="||"] > CallExpression.left': createReporter(
|
|
161
161
|
'allowLogicalExpressionCallExpression',
|
|
162
162
|
context,
|
|
@@ -164,9 +164,9 @@ const rule = {
|
|
|
164
164
|
),
|
|
165
165
|
|
|
166
166
|
/*
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
* object.one && two === 2
|
|
168
|
+
* object.one || two === 2
|
|
169
|
+
*/
|
|
170
170
|
'LogicalExpression[operator="&&"] > MemberExpression.left, LogicalExpression[operator="||"] > MemberExpression.left': createReporter(
|
|
171
171
|
'allowLogicalExpressionMemberExpression',
|
|
172
172
|
context,
|
|
@@ -174,9 +174,9 @@ const rule = {
|
|
|
174
174
|
),
|
|
175
175
|
|
|
176
176
|
/*
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
* object?.one && two === 2
|
|
178
|
+
* object?.one || two === 2
|
|
179
|
+
*/
|
|
180
180
|
'LogicalExpression[operator="&&"] > ChainExpression.left, LogicalExpression[operator="||"] > ChainExpression.left': createReporter(
|
|
181
181
|
'allowLogicalExpressionChainExpression',
|
|
182
182
|
context,
|
package/src/index.js
CHANGED
|
@@ -47,8 +47,8 @@ const configBuilders = [
|
|
|
47
47
|
];
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* @param {import('node:url').URL} root The root url object for the project config
|
|
51
|
-
* @returns {Promise<import('eslint').Linter.
|
|
50
|
+
* @param {import('node:url').URL} root - The root url object for the project config.
|
|
51
|
+
* @returns {Promise<import('eslint').Linter.Config[]>}
|
|
52
52
|
*/
|
|
53
53
|
async function createConfigUrl(root) {
|
|
54
54
|
const configs = await Promise.all(
|
|
@@ -59,8 +59,8 @@ async function createConfigUrl(root) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* @param {string | import('node:url').URL} root
|
|
63
|
-
* @returns {Promise<import('eslint').Linter.
|
|
62
|
+
* @param {string | import('node:url').URL} root - Root url.
|
|
63
|
+
* @returns {Promise<import('eslint').Linter.Config[]>}
|
|
64
64
|
*/
|
|
65
65
|
export async function createConfig(root) {
|
|
66
66
|
if (root instanceof URL) {
|
|
@@ -71,11 +71,15 @@ export async function createConfig(root) {
|
|
|
71
71
|
throw new TypeError('Invalid file root');
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
.replace(/^file
|
|
77
|
-
|
|
78
|
-
.
|
|
74
|
+
const [ filepath ] = root
|
|
75
|
+
// This is to remove: file:/ or file:///
|
|
76
|
+
.replace(/^file:\/*/u, '/')
|
|
77
|
+
// This is prevent ?time=<stamp>
|
|
78
|
+
.split('?', 1);
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
if (filepath == null) {
|
|
81
|
+
throw new Error('Cannot compute filepath');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return createConfigUrl(pathToFileURL(filepath));
|
|
81
85
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import eslintComments from '@eslint-community/eslint-plugin-eslint-comments';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Get ESLint config for comments check
|
|
5
|
-
* @returns {import('eslint').Linter.
|
|
4
|
+
* Get ESLint config for comments check.
|
|
5
|
+
* @returns {import('eslint').Linter.Config[]}
|
|
6
6
|
*/
|
|
7
7
|
export function createEslintCommentsConfig() {
|
|
8
8
|
return [
|
|
@@ -19,8 +19,8 @@ export function createEslintCommentsConfig() {
|
|
|
19
19
|
'eslint-comments/no-unused-disable': 'error',
|
|
20
20
|
'eslint-comments/no-unused-enable': 'error',
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
'line-comment-position': 'off',
|
|
23
|
+
'multiline-comment-style': 'off',
|
|
24
24
|
'no-inline-comments': 'off',
|
|
25
25
|
},
|
|
26
26
|
},
|