@ocavue/eslint-config 3.8.6 → 3.9.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/dist/package-json.d.ts +2 -1
- package/dist/package-json.d.ts.map +1 -1
- package/dist/package-json.js +152 -68
- package/dist/package-json.js.map +1 -1
- package/dist/package-json.test.d.ts +2 -0
- package/dist/package-json.test.d.ts.map +1 -0
- package/dist/package-json.test.js +24 -0
- package/dist/package-json.test.js.map +1 -0
- package/dist/test-utils.d.ts +20 -0
- package/dist/test-utils.d.ts.map +1 -0
- package/dist/test-utils.js +108 -0
- package/dist/test-utils.js.map +1 -0
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/unicorn.d.ts +1 -0
- package/dist/unicorn.d.ts.map +1 -1
- package/dist/unicorn.js +83 -78
- package/dist/unicorn.js.map +1 -1
- package/dist/unicorn.test.d.ts +2 -0
- package/dist/unicorn.test.d.ts.map +1 -0
- package/dist/unicorn.test.js +216 -0
- package/dist/unicorn.test.js.map +1 -0
- package/package.json +6 -4
package/dist/package-json.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../src/package-json.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../src/package-json.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAG/C,eAAO,MAAM,gBAAgB,EAAE,KA6L9B,CAAA;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,MAAM,EAAE,CAStC"}
|
package/dist/package-json.js
CHANGED
|
@@ -1,77 +1,161 @@
|
|
|
1
1
|
import pkgJson from 'eslint-plugin-package-json';
|
|
2
|
+
// @keep-sorted
|
|
3
|
+
export const packageJsonRules = {
|
|
4
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/no-redundant-files.md
|
|
5
|
+
'package-json/no-redundant-files': 'error',
|
|
6
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/no-redundant-publishConfig.md
|
|
7
|
+
'package-json/no-redundant-publishConfig': 'error',
|
|
8
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/order-properties.md
|
|
9
|
+
'package-json/order-properties': [
|
|
10
|
+
'warn',
|
|
11
|
+
{
|
|
12
|
+
order: [
|
|
13
|
+
'name',
|
|
14
|
+
'displayName',
|
|
15
|
+
'publisher',
|
|
16
|
+
'type',
|
|
17
|
+
'version',
|
|
18
|
+
'private',
|
|
19
|
+
'packageManager',
|
|
20
|
+
'description',
|
|
21
|
+
'author',
|
|
22
|
+
'license',
|
|
23
|
+
'funding',
|
|
24
|
+
'homepage',
|
|
25
|
+
'repository',
|
|
26
|
+
'bugs',
|
|
27
|
+
'contributes',
|
|
28
|
+
'keywords',
|
|
29
|
+
'categories',
|
|
30
|
+
'sideEffects',
|
|
31
|
+
'main',
|
|
32
|
+
'module',
|
|
33
|
+
'types',
|
|
34
|
+
'style',
|
|
35
|
+
'exports',
|
|
36
|
+
'typesVersions',
|
|
37
|
+
'bin',
|
|
38
|
+
'icon',
|
|
39
|
+
'files',
|
|
40
|
+
'engines',
|
|
41
|
+
'scripts',
|
|
42
|
+
'dependencies',
|
|
43
|
+
'peerDependencies',
|
|
44
|
+
'peerDependenciesMeta',
|
|
45
|
+
'optionalDependencies',
|
|
46
|
+
'devDependencies',
|
|
47
|
+
'publishConfig',
|
|
48
|
+
'overrides',
|
|
49
|
+
'resolutions',
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/repository-shorthand.md
|
|
54
|
+
'package-json/repository-shorthand': 'error',
|
|
55
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/require-license.md
|
|
56
|
+
'package-json/require-license': 'warn',
|
|
57
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/require-name.md
|
|
58
|
+
'package-json/require-name': 'warn',
|
|
59
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/require-type.md
|
|
60
|
+
'package-json/require-type': 'error',
|
|
61
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/require-version.md
|
|
62
|
+
'package-json/require-version': 'error',
|
|
63
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/sort-collections.md
|
|
64
|
+
'package-json/sort-collections': [
|
|
65
|
+
'warn',
|
|
66
|
+
[
|
|
67
|
+
// Copied from the link below but remove "scripts" because we don't
|
|
68
|
+
// want to sort scripts
|
|
69
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/src/rules/sort-collections.ts#L7
|
|
70
|
+
'config',
|
|
71
|
+
'dependencies',
|
|
72
|
+
'devDependencies',
|
|
73
|
+
'exports',
|
|
74
|
+
'optionalDependencies',
|
|
75
|
+
'overrides',
|
|
76
|
+
'peerDependencies',
|
|
77
|
+
'peerDependenciesMeta',
|
|
78
|
+
],
|
|
79
|
+
],
|
|
80
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/specify-peers-locally.md
|
|
81
|
+
'package-json/specify-peers-locally': 'error',
|
|
82
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/unique-dependencies.md
|
|
83
|
+
'package-json/unique-dependencies': 'error',
|
|
84
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-author.md
|
|
85
|
+
'package-json/valid-author': 'error',
|
|
86
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-bin.md
|
|
87
|
+
'package-json/valid-bin': 'error',
|
|
88
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-bundleDependencies.md
|
|
89
|
+
'package-json/valid-bundleDependencies': 'error',
|
|
90
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-config.md
|
|
91
|
+
'package-json/valid-config': 'error',
|
|
92
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-contributors.md
|
|
93
|
+
'package-json/valid-contributors': 'error',
|
|
94
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-cpu.md
|
|
95
|
+
'package-json/valid-cpu': 'error',
|
|
96
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-dependencies.md
|
|
97
|
+
'package-json/valid-dependencies': 'error',
|
|
98
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-description.md
|
|
99
|
+
'package-json/valid-description': 'error',
|
|
100
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-devDependencies.md
|
|
101
|
+
'package-json/valid-devDependencies': 'error',
|
|
102
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-directories.md
|
|
103
|
+
'package-json/valid-directories': 'error',
|
|
104
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-engines.md
|
|
105
|
+
'package-json/valid-engines': 'error',
|
|
106
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-exports.md
|
|
107
|
+
'package-json/valid-exports': 'error',
|
|
108
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-files.md
|
|
109
|
+
'package-json/valid-files': 'error',
|
|
110
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-homepage.md
|
|
111
|
+
'package-json/valid-homepage': 'error',
|
|
112
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-keywords.md
|
|
113
|
+
'package-json/valid-keywords': 'error',
|
|
114
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-license.md
|
|
115
|
+
'package-json/valid-license': 'error',
|
|
116
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-main.md
|
|
117
|
+
'package-json/valid-main': 'error',
|
|
118
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-man.md
|
|
119
|
+
'package-json/valid-man': 'error',
|
|
120
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-module.md
|
|
121
|
+
'package-json/valid-module': 'error',
|
|
122
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-name.md
|
|
123
|
+
'package-json/valid-name': 'error',
|
|
124
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-optionalDependencies.md
|
|
125
|
+
'package-json/valid-optionalDependencies': 'error',
|
|
126
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-os.md
|
|
127
|
+
'package-json/valid-os': 'error',
|
|
128
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-peerDependencies.md
|
|
129
|
+
'package-json/valid-peerDependencies': 'error',
|
|
130
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-private.md
|
|
131
|
+
'package-json/valid-private': 'error',
|
|
132
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-publishConfig.md
|
|
133
|
+
'package-json/valid-publishConfig': 'error',
|
|
134
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-repository-directory.md
|
|
135
|
+
'package-json/valid-repository-directory': 'error',
|
|
136
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-repository.md
|
|
137
|
+
'package-json/valid-repository': 'error',
|
|
138
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-scripts.md
|
|
139
|
+
'package-json/valid-scripts': 'error',
|
|
140
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-sideEffects.md
|
|
141
|
+
'package-json/valid-sideEffects': 'error',
|
|
142
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-type.md
|
|
143
|
+
'package-json/valid-type': 'error',
|
|
144
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-version.md
|
|
145
|
+
'package-json/valid-version': 'error',
|
|
146
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/valid-workspaces.md
|
|
147
|
+
'package-json/valid-workspaces': 'error',
|
|
148
|
+
};
|
|
2
149
|
/**
|
|
3
150
|
* Sort package.json keys
|
|
4
151
|
*/
|
|
5
152
|
export function packageJson() {
|
|
6
153
|
const pkgJsonConfig = pkgJson.configs.recommended;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'package-json/no-empty-fields': 'off',
|
|
12
|
-
'package-json/require-description': 'off',
|
|
13
|
-
'package-json/sort-collections': [
|
|
14
|
-
'warn',
|
|
15
|
-
[
|
|
16
|
-
// Copied from the link below but remove "scripts" because we don't
|
|
17
|
-
// want to sort scripts
|
|
18
|
-
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/src/rules/sort-collections.ts#L7
|
|
19
|
-
'config',
|
|
20
|
-
'dependencies',
|
|
21
|
-
'devDependencies',
|
|
22
|
-
'exports',
|
|
23
|
-
'optionalDependencies',
|
|
24
|
-
'overrides',
|
|
25
|
-
'peerDependencies',
|
|
26
|
-
'peerDependenciesMeta',
|
|
27
|
-
],
|
|
28
|
-
],
|
|
29
|
-
'package-json/order-properties': [
|
|
30
|
-
'warn',
|
|
31
|
-
{
|
|
32
|
-
order: [
|
|
33
|
-
'name',
|
|
34
|
-
'displayName',
|
|
35
|
-
'publisher',
|
|
36
|
-
'type',
|
|
37
|
-
'version',
|
|
38
|
-
'private',
|
|
39
|
-
'packageManager',
|
|
40
|
-
'description',
|
|
41
|
-
'author',
|
|
42
|
-
'license',
|
|
43
|
-
'funding',
|
|
44
|
-
'homepage',
|
|
45
|
-
'repository',
|
|
46
|
-
'bugs',
|
|
47
|
-
'contributes',
|
|
48
|
-
'keywords',
|
|
49
|
-
'categories',
|
|
50
|
-
'sideEffects',
|
|
51
|
-
'main',
|
|
52
|
-
'module',
|
|
53
|
-
'types',
|
|
54
|
-
'style',
|
|
55
|
-
'exports',
|
|
56
|
-
'typesVersions',
|
|
57
|
-
'bin',
|
|
58
|
-
'icon',
|
|
59
|
-
'files',
|
|
60
|
-
'engines',
|
|
61
|
-
'scripts',
|
|
62
|
-
'dependencies',
|
|
63
|
-
'peerDependencies',
|
|
64
|
-
'peerDependenciesMeta',
|
|
65
|
-
'optionalDependencies',
|
|
66
|
-
'devDependencies',
|
|
67
|
-
'publishConfig',
|
|
68
|
-
'overrides',
|
|
69
|
-
'resolutions',
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
],
|
|
154
|
+
return [
|
|
155
|
+
{
|
|
156
|
+
...pkgJsonConfig,
|
|
157
|
+
rules: packageJsonRules,
|
|
73
158
|
},
|
|
74
|
-
|
|
75
|
-
return [config];
|
|
159
|
+
];
|
|
76
160
|
}
|
|
77
161
|
//# sourceMappingURL=package-json.js.map
|
package/dist/package-json.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-json.js","sourceRoot":"","sources":["../src/package-json.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,4BAA4B,CAAA;AAIhD
|
|
1
|
+
{"version":3,"file":"package-json.js","sourceRoot":"","sources":["../src/package-json.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,4BAA4B,CAAA;AAIhD,eAAe;AACf,MAAM,CAAC,MAAM,gBAAgB,GAAU;IAErC,8GAA8G;IAC9G,iCAAiC,EAAE,OAAO;IAE1C,sHAAsH;IACtH,yCAAyC,EAAE,OAAO;IAElD,4GAA4G;IAC5G,+BAA+B,EAAE;QAC/B,MAAM;QACN;YACE,KAAK,EAAE;gBACL,MAAM;gBACN,aAAa;gBACb,WAAW;gBACX,MAAM;gBACN,SAAS;gBACT,SAAS;gBACT,gBAAgB;gBAChB,aAAa;gBACb,QAAQ;gBACR,SAAS;gBACT,SAAS;gBACT,UAAU;gBACV,YAAY;gBACZ,MAAM;gBACN,aAAa;gBACb,UAAU;gBACV,YAAY;gBACZ,aAAa;gBACb,MAAM;gBACN,QAAQ;gBACR,OAAO;gBACP,OAAO;gBACP,SAAS;gBACT,eAAe;gBACf,KAAK;gBACL,MAAM;gBACN,OAAO;gBACP,SAAS;gBACT,SAAS;gBACT,cAAc;gBACd,kBAAkB;gBAClB,sBAAsB;gBACtB,sBAAsB;gBACtB,iBAAiB;gBACjB,eAAe;gBACf,WAAW;gBACX,aAAa;aACd;SACF;KACF;IAED,gHAAgH;IAChH,mCAAmC,EAAE,OAAO;IAG5C,2GA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ACxG,2BAA2B,EAAE,OAAO;IAEpC,sGAAsG;IACtG,yBAAyB,EAAE,OAAO;IAElC,sHAAsH;IACtH,yCAAyC,EAAE,OAAO;IAElD,oGAAoG;IACpG,uBAAuB,EAAE,OAAO;IAEhC,kHAAkH;IAClH,qCAAqC,EAAE,OAAO;IAE9C,yGAAyG;IACzG,4BAA4B,EAAE,OAAO;IAErC,+GAA+G;IAC/G,kCAAkC,EAAE,OAAO;IAE3C,sHAAsH;IACtH,yCAAyC,EAAE,OAAO;IAElD,4GAA4G;IAC5G,+BAA+B,EAAE,OAAO;IAExC,yGAAyG;IACzG,4BAA4B,EAAE,OAAO;IAErC,6GAA6G;IAC7G,gCAAgC,EAAE,OAAO;IAEzC,sGAAsG;IACtG,yBAAyB,EAAE,OAAO;IAElC,yGAAyG;IACzG,4BAA4B,EAAE,OAAO;IAErC,4GAA4G;IAC5G,+BAA+B,EAAE,OAAO;CACzC,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,aAAa,GAAW,OAAO,CAAC,OAAO,CAAC,WAAW,CAAA;IAEzD,OAAO;QACL;YACE,GAAG,aAAa;YAChB,KAAK,EAAE,gBAAgB;SACxB;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-json.test.d.ts","sourceRoot":"","sources":["../src/package-json.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import pkgJson from 'eslint-plugin-package-json';
|
|
2
|
+
import { test } from 'vitest';
|
|
3
|
+
import { packageJsonRules } from "./package-json.js";
|
|
4
|
+
import { checkRules } from "./test-utils.js";
|
|
5
|
+
test('package-json rules should match recommended rules', () => {
|
|
6
|
+
const plugin = pkgJson.configs.recommended.plugins['package-json'];
|
|
7
|
+
const recommendedRules = pkgJson.configs?.recommended?.rules || {};
|
|
8
|
+
checkRules({
|
|
9
|
+
plugin,
|
|
10
|
+
currentRules: packageJsonRules,
|
|
11
|
+
recommendedRules,
|
|
12
|
+
disabledRules: [
|
|
13
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/no-empty-fields.md
|
|
14
|
+
'package-json/no-empty-fields',
|
|
15
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/require-description.md
|
|
16
|
+
'package-json/require-description',
|
|
17
|
+
],
|
|
18
|
+
enabledRules: [
|
|
19
|
+
// https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/blob/v0.88.1/docs/rules/order-properties.md
|
|
20
|
+
'package-json/order-properties',
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=package-json.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-json.test.js","sourceRoot":"","sources":["../src/package-json.test.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,4BAA4B,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,IAAI,CAAC,mDAAmD,EAAE,GAAG,EAAE;IAC7D,MAAM,MAAM,GAAW,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IAC1E,MAAM,gBAAgB,GAAU,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,IAAI,EAAE,CAAA;IAEzE,UAAU,CAAC;QACT,MAAM;QACN,YAAY,EAAE,gBAAgB;QAC9B,gBAAgB;QAChB,aAAa,EAAE;YACb,2GAA2G;YAC3G,8BAA8B;YAE9B,+GAA+G;YAC/G,kCAAkC;SACnC;QACD,YAAY,EAAE;YACZ,4GAA4G;YAC5G,+BAA+B;SAChC;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Plugin, Rules } from './types.ts';
|
|
2
|
+
export declare function collectEnabledRuleNames(rules: Partial<Rules>): string[];
|
|
3
|
+
export declare function getRuleLink(plugin: Plugin, ruleName: string): string | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Check that all rule differences between recommended and current configs are explicitly declared.
|
|
6
|
+
*
|
|
7
|
+
* This function ensures that:
|
|
8
|
+
* 1. All recommended rules are either used or explicitly disabled with a reason
|
|
9
|
+
* 2. All extra enabled rules are explicitly declared with a reason
|
|
10
|
+
*
|
|
11
|
+
* When differences are found, detailed error messages with documentation links are shown.
|
|
12
|
+
*/
|
|
13
|
+
export declare function checkRules(options: {
|
|
14
|
+
plugin: Plugin;
|
|
15
|
+
currentRules: Rules;
|
|
16
|
+
recommendedRules: Rules;
|
|
17
|
+
disabledRules: string[];
|
|
18
|
+
enabledRules: string[];
|
|
19
|
+
}): void;
|
|
20
|
+
//# sourceMappingURL=test-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAE/C,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE,CAYvE;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,SAAS,CAcpB;AA8BD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,KAAK,CAAA;IACnB,gBAAgB,EAAE,KAAK,CAAA;IACvB,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,YAAY,EAAE,MAAM,EAAE,CAAA;CACvB,GAAG,IAAI,CA6EP"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { expect } from 'vitest';
|
|
2
|
+
export function collectEnabledRuleNames(rules) {
|
|
3
|
+
const enabledRuleNames = [];
|
|
4
|
+
for (const [ruleName, ruleConfig] of Object.entries(rules)) {
|
|
5
|
+
if (ruleConfig == null)
|
|
6
|
+
continue;
|
|
7
|
+
if (ruleConfig === 'off' || ruleConfig === 0)
|
|
8
|
+
continue;
|
|
9
|
+
if (Array.isArray(ruleConfig)) {
|
|
10
|
+
const severity = ruleConfig[0];
|
|
11
|
+
if (severity === 'off' || severity === 0)
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
enabledRuleNames.push(ruleName);
|
|
15
|
+
}
|
|
16
|
+
return enabledRuleNames;
|
|
17
|
+
}
|
|
18
|
+
export function getRuleLink(plugin, ruleName) {
|
|
19
|
+
const ruleNames = [ruleName];
|
|
20
|
+
if (ruleName.includes('/')) {
|
|
21
|
+
ruleNames.push(ruleName.split('/', 2)[1]);
|
|
22
|
+
}
|
|
23
|
+
for (const name of ruleNames) {
|
|
24
|
+
const link = plugin.rules?.[name]?.meta?.docs?.url;
|
|
25
|
+
if (link) {
|
|
26
|
+
return link;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Format a rule violation message with documentation link
|
|
33
|
+
*/
|
|
34
|
+
function formatRuleViolation(type, ruleName, details) {
|
|
35
|
+
const separator = '━'.repeat(60);
|
|
36
|
+
let output = `${separator}\n`;
|
|
37
|
+
output += `❌ ${type}: ${ruleName}\n\n`;
|
|
38
|
+
output += ` ${details.message}\n`;
|
|
39
|
+
if (details.link) {
|
|
40
|
+
output += `\n 📖 Documentation: ${details.link}\n`;
|
|
41
|
+
}
|
|
42
|
+
output += `\n 💡 Fix: ${details.fix}\n`;
|
|
43
|
+
output += separator;
|
|
44
|
+
return output;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check that all rule differences between recommended and current configs are explicitly declared.
|
|
48
|
+
*
|
|
49
|
+
* This function ensures that:
|
|
50
|
+
* 1. All recommended rules are either used or explicitly disabled with a reason
|
|
51
|
+
* 2. All extra enabled rules are explicitly declared with a reason
|
|
52
|
+
*
|
|
53
|
+
* When differences are found, detailed error messages with documentation links are shown.
|
|
54
|
+
*/
|
|
55
|
+
export function checkRules(options) {
|
|
56
|
+
const { plugin, currentRules, recommendedRules, disabledRules, enabledRules, } = options;
|
|
57
|
+
const violations = [];
|
|
58
|
+
const normalizedDisabled = new Set(disabledRules);
|
|
59
|
+
const normalizedEnabled = new Set(enabledRules);
|
|
60
|
+
const recommendedRuleNames = collectEnabledRuleNames(recommendedRules);
|
|
61
|
+
const currentRuleNames = collectEnabledRuleNames(currentRules);
|
|
62
|
+
const recommendedSet = new Set(recommendedRuleNames);
|
|
63
|
+
// 1. Check missing recommended rules (should be in disabledRules)
|
|
64
|
+
for (const ruleName of recommendedRuleNames) {
|
|
65
|
+
if (!(ruleName in currentRules) && !normalizedDisabled.has(ruleName)) {
|
|
66
|
+
const link = getRuleLink(plugin, ruleName);
|
|
67
|
+
violations.push(formatRuleViolation('Missing Disabled Declaration', ruleName, {
|
|
68
|
+
message: 'This rule is recommended but not in your config.',
|
|
69
|
+
fix: `Add to disabledRules array:\n '${ruleName}',`,
|
|
70
|
+
link,
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// 2. Check unnecessary disabled rules (not actually recommended)
|
|
75
|
+
for (const ruleName of disabledRules) {
|
|
76
|
+
if (!recommendedSet.has(ruleName)) {
|
|
77
|
+
violations.push(formatRuleViolation('Unnecessary Disabled Declaration', ruleName, {
|
|
78
|
+
message: 'This rule is not recommended, no need to disable it.',
|
|
79
|
+
fix: `Remove '${ruleName}' from disabledRules array`,
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// 3. Check undeclared extra rules (should be in enabledRules)
|
|
84
|
+
for (const ruleName of currentRuleNames) {
|
|
85
|
+
if (!recommendedSet.has(ruleName) && !normalizedEnabled.has(ruleName)) {
|
|
86
|
+
const link = getRuleLink(plugin, ruleName);
|
|
87
|
+
violations.push(formatRuleViolation('Undeclared Extra Rule', ruleName, {
|
|
88
|
+
message: 'This rule is not recommended but you enabled it.',
|
|
89
|
+
fix: `Add to enabledRules array:\n '${ruleName}',`,
|
|
90
|
+
link,
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// 4. Check unnecessary enabled rules (actually recommended)
|
|
95
|
+
for (const ruleName of enabledRules) {
|
|
96
|
+
if (recommendedSet.has(ruleName)) {
|
|
97
|
+
violations.push(formatRuleViolation('Unnecessary Enabled Declaration', ruleName, {
|
|
98
|
+
message: 'This rule is already recommended, no need to declare as enabled.',
|
|
99
|
+
fix: `Remove '${ruleName}' from enabledRules array`,
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Report all violations
|
|
104
|
+
if (violations.length > 0) {
|
|
105
|
+
expect.fail('\n\n' + violations.join('\n\n'));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=test-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAI/B,MAAM,UAAU,uBAAuB,CAAC,KAAqB;IAC3D,MAAM,gBAAgB,GAAa,EAAE,CAAA;IACrC,KAAK,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3D,IAAI,UAAU,IAAI,IAAI;YAAE,SAAQ;QAChC,IAAI,UAAU,KAAK,KAAK,IAAI,UAAU,KAAK,CAAC;YAAE,SAAQ;QACtD,IAAI,KAAK,CAAC,O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AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE5C,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;AAElC,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;AAE/C,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA"}
|
package/dist/unicorn.d.ts
CHANGED
package/dist/unicorn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unicorn.d.ts","sourceRoot":"","sources":["../src/unicorn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"unicorn.d.ts","sourceRoot":"","sources":["../src/unicorn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAIpC,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,WAsHjC,CAAA;AAED,wBAAgB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,CAUzC"}
|
package/dist/unicorn.js
CHANGED
|
@@ -1,4 +1,86 @@
|
|
|
1
1
|
import plugin from 'eslint-plugin-unicorn';
|
|
2
|
+
// @keep-sorted
|
|
3
|
+
export const unicornRules = {
|
|
4
|
+
// Improve regexes
|
|
5
|
+
'unicorn/better-regex': 'error',
|
|
6
|
+
// Pass error message when throwing errors
|
|
7
|
+
'unicorn/error-message': 'error',
|
|
8
|
+
// Uppercase regex escapes
|
|
9
|
+
'unicorn/escape-case': 'error',
|
|
10
|
+
// Enforce explicitly comparing the length or size property of a value
|
|
11
|
+
'unicorn/explicit-length-check': 'error',
|
|
12
|
+
// Disallow eslint-disable comments without specific rule names
|
|
13
|
+
'unicorn/no-abusive-eslint-disable': 'error',
|
|
14
|
+
// Prevent recursive getters/setters from calling themselves
|
|
15
|
+
'unicorn/no-accessor-recursion': 'warn',
|
|
16
|
+
// Do not use a `for` loop that can be replaced with a `for-of` loop.
|
|
17
|
+
'unicorn/no-for-loop': 'error',
|
|
18
|
+
// Prefer Unicode escapes over hexadecimal escapes
|
|
19
|
+
'unicorn/no-hex-escape': 'warn',
|
|
20
|
+
// Array.isArray instead of instanceof etc
|
|
21
|
+
'unicorn/no-instanceof-builtins': 'error',
|
|
22
|
+
// Avoid passing expressions to removeEventListener
|
|
23
|
+
'unicorn/no-invalid-remove-event-listener': 'warn',
|
|
24
|
+
// Disallow named usage of default import/export
|
|
25
|
+
'unicorn/no-named-default': 'warn',
|
|
26
|
+
// Disallow negating the left side in equality checks
|
|
27
|
+
'unicorn/no-negation-in-equality-check': 'warn',
|
|
28
|
+
// Prevent deprecated `new Buffer()`
|
|
29
|
+
'unicorn/no-new-buffer': 'error',
|
|
30
|
+
// Keep regex literals safe!
|
|
31
|
+
'unicorn/no-unsafe-regex': 'off',
|
|
32
|
+
// Disallow spreading when direct usage works
|
|
33
|
+
'unicorn/no-useless-spread': 'warn',
|
|
34
|
+
// Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
|
|
35
|
+
'unicorn/number-literal-case': 'error',
|
|
36
|
+
// Prefer `.addEventListener()` and `.removeEventListener()` over `on`-functions.
|
|
37
|
+
'unicorn/prefer-add-event-listener': 'error',
|
|
38
|
+
// Prefer `.find(…)` and `.findLast(…)` over the first or last element from
|
|
39
|
+
'unicorn/prefer-array-find': 'error',
|
|
40
|
+
// Prefer `.flatMap(…)` over `.map(…).flat()`.
|
|
41
|
+
'unicorn/prefer-array-flat-map': 'error',
|
|
42
|
+
// Prefer Array#flat over manual flattening
|
|
43
|
+
'unicorn/prefer-array-flat': 'warn',
|
|
44
|
+
// Prefer `.flatMap(…)` over `.map(…).flat()`
|
|
45
|
+
'unicorn/prefer-array-index-of': 'error',
|
|
46
|
+
// Prefer `.some(…)` over `.filter(…).length` check
|
|
47
|
+
'unicorn/prefer-array-some': 'error',
|
|
48
|
+
// Prefer BigInt literals over the constructor
|
|
49
|
+
'unicorn/prefer-bigint-literals': 'warn',
|
|
50
|
+
// Prefer Date.now() to get the number of milliseconds since the Unix Epoch
|
|
51
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-date-now.md
|
|
52
|
+
'unicorn/prefer-date-now': 'warn',
|
|
53
|
+
// Prefer `export…from` when re-exporting
|
|
54
|
+
'unicorn/prefer-export-from': ['warn', { ignoreUsedVariables: true }],
|
|
55
|
+
// Prefer `import.meta.dirname` over `path.dirname(fileURLToPath(import.meta.url))`
|
|
56
|
+
'unicorn/prefer-import-meta-properties': 'warn',
|
|
57
|
+
// includes over indexOf when checking for existence
|
|
58
|
+
'unicorn/prefer-includes': 'error',
|
|
59
|
+
// Prefer `KeyboardEvent#key` over `KeyboardEvent#keyCode`
|
|
60
|
+
'unicorn/prefer-keyboard-event-key': 'error',
|
|
61
|
+
// Enforce the use of `Math.trunc` instead of bitwise operators.
|
|
62
|
+
'unicorn/prefer-math-trunc': 'error',
|
|
63
|
+
// Prefer negative index over `.length - index` when possible
|
|
64
|
+
'unicorn/prefer-negative-index': 'error',
|
|
65
|
+
// Prefer using the node: protocol
|
|
66
|
+
'unicorn/prefer-node-protocol': 'error',
|
|
67
|
+
// Prefer `Number` static properties over global ones.
|
|
68
|
+
'unicorn/prefer-number-properties': 'warn',
|
|
69
|
+
// Prefer `RegExp#test()` over `String#match()` and `RegExp#exec()`
|
|
70
|
+
'unicorn/prefer-regexp-test': 'warn',
|
|
71
|
+
// Enforce combining multiple `Array#push()` into one call.
|
|
72
|
+
'unicorn/prefer-single-call': 'warn',
|
|
73
|
+
// Prefer using the `String.raw` tag to avoid escaping `\`
|
|
74
|
+
'unicorn/prefer-string-raw': 'warn',
|
|
75
|
+
// String methods startsWith/endsWith instead of more complicated stuff
|
|
76
|
+
'unicorn/prefer-string-starts-ends-with': 'error',
|
|
77
|
+
// Prefer using `structuredClone` to create a deep clone
|
|
78
|
+
'unicorn/prefer-structured-clone': 'warn',
|
|
79
|
+
// Enforce throwing type error when throwing error while checking typeof
|
|
80
|
+
'unicorn/prefer-type-error': 'error',
|
|
81
|
+
// Use new when throwing error
|
|
82
|
+
'unicorn/throw-new-error': 'error',
|
|
83
|
+
};
|
|
2
84
|
export function unicorn() {
|
|
3
85
|
return [
|
|
4
86
|
{
|
|
@@ -6,84 +88,7 @@ export function unicorn() {
|
|
|
6
88
|
plugins: {
|
|
7
89
|
unicorn: plugin,
|
|
8
90
|
},
|
|
9
|
-
rules:
|
|
10
|
-
// Pass error message when throwing errors
|
|
11
|
-
'unicorn/error-message': 'error',
|
|
12
|
-
// Uppercase regex escapes
|
|
13
|
-
'unicorn/escape-case': 'error',
|
|
14
|
-
// Prevent recursive getters/setters from calling themselves
|
|
15
|
-
'unicorn/no-accessor-recursion': 'warn',
|
|
16
|
-
// Array.isArray instead of instanceof etc
|
|
17
|
-
'unicorn/no-instanceof-builtins': 'error',
|
|
18
|
-
// Prefer Unicode escapes over hexadecimal escapes
|
|
19
|
-
'unicorn/no-hex-escape': 'warn',
|
|
20
|
-
// Prevent deprecated `new Buffer()`
|
|
21
|
-
'unicorn/no-new-buffer': 'error',
|
|
22
|
-
// Avoid passing expressions to removeEventListener
|
|
23
|
-
'unicorn/no-invalid-remove-event-listener': 'warn',
|
|
24
|
-
// Disallow named usage of default import/export
|
|
25
|
-
'unicorn/no-named-default': 'warn',
|
|
26
|
-
// Disallow negating the left side in equality checks
|
|
27
|
-
'unicorn/no-negation-in-equality-check': 'warn',
|
|
28
|
-
// Keep regex literals safe!
|
|
29
|
-
'unicorn/no-unsafe-regex': 'off',
|
|
30
|
-
// Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
|
|
31
|
-
'unicorn/number-literal-case': 'error',
|
|
32
|
-
// Disallow spreading when direct usage works
|
|
33
|
-
'unicorn/no-useless-spread': 'warn',
|
|
34
|
-
// includes over indexOf when checking for existence
|
|
35
|
-
'unicorn/prefer-includes': 'error',
|
|
36
|
-
// String methods startsWith/endsWith instead of more complicated stuff
|
|
37
|
-
'unicorn/prefer-string-starts-ends-with': 'error',
|
|
38
|
-
// Enforce throwing type error when throwing error while checking typeof
|
|
39
|
-
'unicorn/prefer-type-error': 'error',
|
|
40
|
-
// Use new when throwing error
|
|
41
|
-
'unicorn/throw-new-error': 'error',
|
|
42
|
-
// Prefer using the node: protocol
|
|
43
|
-
'unicorn/prefer-node-protocol': 'error',
|
|
44
|
-
// Enforce explicitly comparing the length or size property of a value
|
|
45
|
-
'unicorn/explicit-length-check': 'error',
|
|
46
|
-
// Prefer `.flatMap(…)` over `.map(…).flat()`
|
|
47
|
-
'unicorn/prefer-array-index-of': 'error',
|
|
48
|
-
// Improve regexes
|
|
49
|
-
'unicorn/better-regex': 'error',
|
|
50
|
-
// Enforce combining multiple `Array#push()` into one call.
|
|
51
|
-
'unicorn/prefer-single-call': 'warn',
|
|
52
|
-
// Do not use a `for` loop that can be replaced with a `for-of` loop.
|
|
53
|
-
'unicorn/no-for-loop': 'error',
|
|
54
|
-
// Disallow eslint-disable comments without specific rule names
|
|
55
|
-
'unicorn/no-abusive-eslint-disable': 'error',
|
|
56
|
-
// Prefer `.addEventListener()` and `.removeEventListener()` over `on`-functions.
|
|
57
|
-
'unicorn/prefer-add-event-listener': 'error',
|
|
58
|
-
// Prefer `.find(…)` and `.findLast(…)` over the first or last element from
|
|
59
|
-
'unicorn/prefer-array-find': 'error',
|
|
60
|
-
// Prefer Array#flat over manual flattening
|
|
61
|
-
'unicorn/prefer-array-flat': 'warn',
|
|
62
|
-
// Prefer `.flatMap(…)` over `.map(…).flat()`.
|
|
63
|
-
'unicorn/prefer-array-flat-map': 'error',
|
|
64
|
-
// Prefer `.some(…)` over `.filter(…).length` check
|
|
65
|
-
'unicorn/prefer-array-some': 'error',
|
|
66
|
-
// Prefer BigInt literals over the constructor
|
|
67
|
-
'unicorn/prefer-bigint-literals': 'warn',
|
|
68
|
-
// Prefer `KeyboardEvent#key` over `KeyboardEvent#keyCode`
|
|
69
|
-
'unicorn/prefer-keyboard-event-key': 'error',
|
|
70
|
-
// Enforce the use of `Math.trunc` instead of bitwise operators.
|
|
71
|
-
'unicorn/prefer-math-trunc': 'error',
|
|
72
|
-
// Prefer negative index over `.length - index` when possible
|
|
73
|
-
'unicorn/prefer-negative-index': 'error',
|
|
74
|
-
// Prefer `Number` static properties over global ones.
|
|
75
|
-
'unicorn/prefer-number-properties': 'warn',
|
|
76
|
-
// Prefer `RegExp#test()` over `String#match()` and `RegExp#exec()`
|
|
77
|
-
'unicorn/prefer-regexp-test': 'warn',
|
|
78
|
-
// Prefer using `structuredClone` to create a deep clone
|
|
79
|
-
'unicorn/prefer-structured-clone': 'warn',
|
|
80
|
-
// Prefer using the `String.raw` tag to avoid escaping `\`
|
|
81
|
-
'unicorn/prefer-string-raw': 'warn',
|
|
82
|
-
// Prefer `import.meta.dirname` over `path.dirname(fileURLToPath(import.meta.url))`
|
|
83
|
-
'unicorn/prefer-import-meta-properties': 'warn',
|
|
84
|
-
// Prefer `export…from` when re-exporting
|
|
85
|
-
'unicorn/prefer-export-from': ['warn', { ignoreUsedVariables: true }],
|
|
86
|
-
},
|
|
91
|
+
rules: unicornRules,
|
|
87
92
|
},
|
|
88
93
|
];
|
|
89
94
|
}
|
package/dist/unicorn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unicorn.js","sourceRoot":"","sources":["../src/unicorn.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,uBAAuB,CAAA;AAE1C,MAAM,
|
|
1
|
+
{"version":3,"file":"unicorn.js","sourceRoot":"","sources":["../src/unicorn.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,uBAAuB,CAAA;AAE1C,eAAe;AAC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AAE,OAAO;IAElC,0DAA0D;IAC1D,mCAAmC,EAAE,OAAO;IAE5C,gEAAgE;IAChE,2BAA2B,EAAE,OAAO;IAEpC,6DAA6D;IAC7D,+BAA+B,EAAE,OAAO;IAExC,kCAAkC;IAClC,8BAA8B,EAAE,OAAO;IAEvC,sDAAsD;IACtD,kCAAkC,EAAE,MAAM;IAE1C,mEAAmE;IACnE,4BAA4B,EAAE,MAAM;IAEpC,2DAA2D;IAC3D,4BAA4B,EAAE,MAAM;IAEpC,0DAA0D;IAC1D,2BAA2B,EAAE,MAAM;IAEnC,uEAAuE;IACvE,wCAAwC,EAAE,OAAO;IAEjD,wDAAwD;IACxD,iCAAiC,EAAE,MAAM;IAEzC,wEAAwE;IACxE,2BAA2B,EAAE,OAAO;IAEpC,8BAA8B;IAC9B,yBAAyB,EAAE,OAAO;CACnC,CAAA;AAED,MAAM,UAAU,OAAO;IACrB,OAAO;QACL;YACE,IAAI,EAAE,SAAS;YACf,OAAO,EAAE;gBACP,OAAO,EAAE,MAAM;aAChB;YACD,KAAK,EAAE,YAAY;SACpB;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unicorn.test.d.ts","sourceRoot":"","sources":["../src/unicorn.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import plugin from 'eslint-plugin-unicorn';
|
|
2
|
+
import { test } from 'vitest';
|
|
3
|
+
import { checkRules } from './test-utils.js';
|
|
4
|
+
import { unicornRules } from './unicorn.js';
|
|
5
|
+
test('Unicorn rules should match recommended rules', () => {
|
|
6
|
+
// @keep-sorted
|
|
7
|
+
const disabledRules = [
|
|
8
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/catch-error-name.md
|
|
9
|
+
'unicorn/catch-error-name',
|
|
10
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/consistent-assert.md
|
|
11
|
+
'unicorn/consistent-assert',
|
|
12
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/consistent-date-clone.md
|
|
13
|
+
'unicorn/consistent-date-clone',
|
|
14
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/consistent-empty-array-spread.md
|
|
15
|
+
'unicorn/consistent-empty-array-spread',
|
|
16
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/consistent-existence-index-check.md
|
|
17
|
+
'unicorn/consistent-existence-index-check',
|
|
18
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/consistent-function-scoping.md
|
|
19
|
+
'unicorn/consistent-function-scoping',
|
|
20
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/empty-brace-spaces.md
|
|
21
|
+
'unicorn/empty-brace-spaces',
|
|
22
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/expiring-todo-comments.md
|
|
23
|
+
'unicorn/expiring-todo-comments',
|
|
24
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/filename-case.md
|
|
25
|
+
'unicorn/filename-case',
|
|
26
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/import-style.md
|
|
27
|
+
'unicorn/import-style',
|
|
28
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/new-for-builtins.md
|
|
29
|
+
'unicorn/new-for-builtins',
|
|
30
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-anonymous-default-export.md
|
|
31
|
+
'unicorn/no-anonymous-default-export',
|
|
32
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-array-callback-reference.md
|
|
33
|
+
'unicorn/no-array-callback-reference',
|
|
34
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-array-for-each.md
|
|
35
|
+
'unicorn/no-array-for-each',
|
|
36
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-array-method-this-argument.md
|
|
37
|
+
'unicorn/no-array-method-this-argument',
|
|
38
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-array-reduce.md
|
|
39
|
+
'unicorn/no-array-reduce',
|
|
40
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-array-reverse.md
|
|
41
|
+
'unicorn/no-array-reverse',
|
|
42
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-array-sort.md
|
|
43
|
+
'unicorn/no-array-sort',
|
|
44
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-await-expression-member.md
|
|
45
|
+
'unicorn/no-await-expression-member',
|
|
46
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-await-in-promise-methods.md
|
|
47
|
+
'unicorn/no-await-in-promise-methods',
|
|
48
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-console-spaces.md
|
|
49
|
+
'unicorn/no-console-spaces',
|
|
50
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-document-cookie.md
|
|
51
|
+
'unicorn/no-document-cookie',
|
|
52
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-empty-file.md
|
|
53
|
+
'unicorn/no-empty-file',
|
|
54
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-immediate-mutation.md
|
|
55
|
+
'unicorn/no-immediate-mutation',
|
|
56
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-invalid-fetch-options.md
|
|
57
|
+
'unicorn/no-invalid-fetch-options',
|
|
58
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-lonely-if.md
|
|
59
|
+
'unicorn/no-lonely-if',
|
|
60
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-magic-array-flat-depth.md
|
|
61
|
+
'unicorn/no-magic-array-flat-depth',
|
|
62
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-negated-condition.md
|
|
63
|
+
'unicorn/no-negated-condition',
|
|
64
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-nested-ternary.md
|
|
65
|
+
'unicorn/no-nested-ternary',
|
|
66
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-new-array.md
|
|
67
|
+
'unicorn/no-new-array',
|
|
68
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-null.md
|
|
69
|
+
'unicorn/no-null',
|
|
70
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-object-as-default-parameter.md
|
|
71
|
+
'unicorn/no-object-as-default-parameter',
|
|
72
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-process-exit.md
|
|
73
|
+
'unicorn/no-process-exit',
|
|
74
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-single-promise-in-promise-methods.md
|
|
75
|
+
'unicorn/no-single-promise-in-promise-methods',
|
|
76
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-static-only-class.md
|
|
77
|
+
'unicorn/no-static-only-class',
|
|
78
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-thenable.md
|
|
79
|
+
'unicorn/no-thenable',
|
|
80
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-this-assignment.md
|
|
81
|
+
'unicorn/no-this-assignment',
|
|
82
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-typeof-undefined.md
|
|
83
|
+
'unicorn/no-typeof-undefined',
|
|
84
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-unnecessary-array-flat-depth.md
|
|
85
|
+
'unicorn/no-unnecessary-array-flat-depth',
|
|
86
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-unnecessary-array-splice-count.md
|
|
87
|
+
'unicorn/no-unnecessary-array-splice-count',
|
|
88
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-unnecessary-await.md
|
|
89
|
+
'unicorn/no-unnecessary-await',
|
|
90
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-unnecessary-polyfills.md
|
|
91
|
+
'unicorn/no-unnecessary-polyfills',
|
|
92
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-unnecessary-slice-end.md
|
|
93
|
+
'unicorn/no-unnecessary-slice-end',
|
|
94
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-unreadable-array-destructuring.md
|
|
95
|
+
'unicorn/no-unreadable-array-destructuring',
|
|
96
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-unreadable-iife.md
|
|
97
|
+
'unicorn/no-unreadable-iife',
|
|
98
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-useless-collection-argument.md
|
|
99
|
+
'unicorn/no-useless-collection-argument',
|
|
100
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-useless-error-capture-stack-trace.md
|
|
101
|
+
'unicorn/no-useless-error-capture-stack-trace',
|
|
102
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-useless-fallback-in-spread.md
|
|
103
|
+
'unicorn/no-useless-fallback-in-spread',
|
|
104
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-useless-length-check.md
|
|
105
|
+
'unicorn/no-useless-length-check',
|
|
106
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-useless-promise-resolve-reject.md
|
|
107
|
+
'unicorn/no-useless-promise-resolve-reject',
|
|
108
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-useless-switch-case.md
|
|
109
|
+
'unicorn/no-useless-switch-case',
|
|
110
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-useless-undefined.md
|
|
111
|
+
'unicorn/no-useless-undefined',
|
|
112
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/no-zero-fractions.md
|
|
113
|
+
'unicorn/no-zero-fractions',
|
|
114
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/numeric-separators-style.md
|
|
115
|
+
'unicorn/numeric-separators-style',
|
|
116
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-at.md
|
|
117
|
+
'unicorn/prefer-at',
|
|
118
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-blob-reading-methods.md
|
|
119
|
+
'unicorn/prefer-blob-reading-methods',
|
|
120
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-class-fields.md
|
|
121
|
+
'unicorn/prefer-class-fields',
|
|
122
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-classlist-toggle.md
|
|
123
|
+
'unicorn/prefer-classlist-toggle',
|
|
124
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-code-point.md
|
|
125
|
+
'unicorn/prefer-code-point',
|
|
126
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-default-parameters.md
|
|
127
|
+
'unicorn/prefer-default-parameters',
|
|
128
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-dom-node-append.md
|
|
129
|
+
'unicorn/prefer-dom-node-append',
|
|
130
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-dom-node-dataset.md
|
|
131
|
+
'unicorn/prefer-dom-node-dataset',
|
|
132
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-dom-node-remove.md
|
|
133
|
+
'unicorn/prefer-dom-node-remove',
|
|
134
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-dom-node-text-content.md
|
|
135
|
+
'unicorn/prefer-dom-node-text-content',
|
|
136
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-event-target.md
|
|
137
|
+
'unicorn/prefer-event-target',
|
|
138
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-global-this.md
|
|
139
|
+
'unicorn/prefer-global-this',
|
|
140
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-logical-operator-over-ternary.md
|
|
141
|
+
'unicorn/prefer-logical-operator-over-ternary',
|
|
142
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-math-min-max.md
|
|
143
|
+
'unicorn/prefer-math-min-max',
|
|
144
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-modern-dom-apis.md
|
|
145
|
+
'unicorn/prefer-modern-dom-apis',
|
|
146
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-modern-math-apis.md
|
|
147
|
+
'unicorn/prefer-modern-math-apis',
|
|
148
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-module.md
|
|
149
|
+
'unicorn/prefer-module',
|
|
150
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-native-coercion-functions.md
|
|
151
|
+
'unicorn/prefer-native-coercion-functions',
|
|
152
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-object-from-entries.md
|
|
153
|
+
'unicorn/prefer-object-from-entries',
|
|
154
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-optional-catch-binding.md
|
|
155
|
+
'unicorn/prefer-optional-catch-binding',
|
|
156
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-prototype-methods.md
|
|
157
|
+
'unicorn/prefer-prototype-methods',
|
|
158
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-query-selector.md
|
|
159
|
+
'unicorn/prefer-query-selector',
|
|
160
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-reflect-apply.md
|
|
161
|
+
'unicorn/prefer-reflect-apply',
|
|
162
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-response-static-json.md
|
|
163
|
+
'unicorn/prefer-response-static-json',
|
|
164
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-set-has.md
|
|
165
|
+
'unicorn/prefer-set-has',
|
|
166
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-set-size.md
|
|
167
|
+
'unicorn/prefer-set-size',
|
|
168
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-spread.md
|
|
169
|
+
'unicorn/prefer-spread',
|
|
170
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-string-replace-all.md
|
|
171
|
+
'unicorn/prefer-string-replace-all',
|
|
172
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-string-slice.md
|
|
173
|
+
'unicorn/prefer-string-slice',
|
|
174
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-string-trim-start-end.md
|
|
175
|
+
'unicorn/prefer-string-trim-start-end',
|
|
176
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-switch.md
|
|
177
|
+
'unicorn/prefer-switch',
|
|
178
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-ternary.md
|
|
179
|
+
'unicorn/prefer-ternary',
|
|
180
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-top-level-await.md
|
|
181
|
+
'unicorn/prefer-top-level-await',
|
|
182
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prevent-abbreviations.md
|
|
183
|
+
'unicorn/prevent-abbreviations',
|
|
184
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/relative-url-style.md
|
|
185
|
+
'unicorn/relative-url-style',
|
|
186
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/require-array-join-separator.md
|
|
187
|
+
'unicorn/require-array-join-separator',
|
|
188
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/require-module-attributes.md
|
|
189
|
+
'unicorn/require-module-attributes',
|
|
190
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/require-module-specifiers.md
|
|
191
|
+
'unicorn/require-module-specifiers',
|
|
192
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/require-number-to-fixed-digits-argument.md
|
|
193
|
+
'unicorn/require-number-to-fixed-digits-argument',
|
|
194
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/switch-case-braces.md
|
|
195
|
+
'unicorn/switch-case-braces',
|
|
196
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/template-indent.md
|
|
197
|
+
'unicorn/template-indent',
|
|
198
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/text-encoding-identifier-case.md
|
|
199
|
+
'unicorn/text-encoding-identifier-case',
|
|
200
|
+
];
|
|
201
|
+
// @keep-sorted
|
|
202
|
+
const enabledRules = [
|
|
203
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/better-regex.md
|
|
204
|
+
'unicorn/better-regex',
|
|
205
|
+
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v62.0.0/docs/rules/prefer-import-meta-properties.md
|
|
206
|
+
'unicorn/prefer-import-meta-properties',
|
|
207
|
+
];
|
|
208
|
+
checkRules({
|
|
209
|
+
plugin,
|
|
210
|
+
currentRules: unicornRules,
|
|
211
|
+
recommendedRules: plugin.configs.recommended.rules || {},
|
|
212
|
+
disabledRules,
|
|
213
|
+
enabledRules,
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
//# sourceMappingURL=unicorn.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unicorn.test.js","sourceRoot":"","sources":["../src/unicorn.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,uBAAuB,CAAA;AAC1C,OAAO,EAAE,IAAI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QAC5G,kCAAkC;QAElC,yGAAyG;QACzG,+BAA+B;QAE/B,wGAAwG;QACxG,8BAA8B;QAE9B,+GAA+G;QAC/G,qCAAqC;QAErC,kGAAkG;QAClG,wBAAwB;QAExB,mGAAmG;QACnG,yBAAyB;QAEzB,iGAAiG;QACjG,uBAAuB;QAEvB,6GAA6G;QAC7G,mCAAmC;QAEnC,uGAAuG;QACvG,6BAA6B;QAE7B,gHAAgH;QAChH,sCAAsC;QAEtC,iGAAiG;QACjG,uBAAuB;QAEvB,kGAAkG;QAClG,wBAAwB;QAExB,0GAA0G;QAC1G,gCAAgC;QAEhC,yGAAyG;QACzG,+BAA+B;QAE/B,sGAAsG;QACtG,4BAA4B;QAE5B,gHAAgH;QAChH,sCAAsC;QAEtC,6GAA6G;QAC7G,mCAAmC;QAEnC,6GAA6G;QAC7G,mCAAmC;QAEnC,2HAA2H;QAC3H,iDAAiD;QAEjD,sGAAsG;QACtG,4BAA4B;QAE5B,mGAAmG;QACnG,yBAAyB;QAEzB,iHAAiH;QACjH,uCAAuC;KACxC,CAAA;IAED,eAAe;IACf,MAAM,YAAY,GAAG;QACnB,gGAAgG;QAChG,sBAAsB;QAEtB,iHAAiH;QACjH,uCAAuC;KACxC,CAAA;IAED,UAAU,CAAC;QACT,MAAM;QACN,YAAY,EAAE,YAAY;QAC1B,gBAAgB,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE;QACxD,aAAa;QACb,YAAY;KACb,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocavue/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.9.0",
|
|
5
5
|
"description": "Opinionated ESLint config preset",
|
|
6
6
|
"author": "ocavue <ocavue@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -43,18 +43,19 @@
|
|
|
43
43
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
44
44
|
"eslint-plugin-unicorn": "^62.0.0",
|
|
45
45
|
"eslint-plugin-vue": "^10.6.2",
|
|
46
|
-
"globals": "^
|
|
46
|
+
"globals": "^17.0.0",
|
|
47
47
|
"typescript-eslint": "^8.52.0",
|
|
48
48
|
"vue-eslint-parser": "^10.2.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@ocavue/tsconfig": "^0.6.2",
|
|
52
|
-
"@types/node": "^20.
|
|
52
|
+
"@types/node": "^20.19.27",
|
|
53
53
|
"eslint": "^9.39.2",
|
|
54
54
|
"jiti": "^2.6.1",
|
|
55
55
|
"pkg-pr-new": "^0.0.62",
|
|
56
56
|
"prettier": "^3.7.4",
|
|
57
|
-
"typescript": "^5.9.3"
|
|
57
|
+
"typescript": "^5.9.3",
|
|
58
|
+
"vitest": "^4.0.16"
|
|
58
59
|
},
|
|
59
60
|
"renovate": {
|
|
60
61
|
"extends": [
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
]
|
|
63
64
|
},
|
|
64
65
|
"scripts": {
|
|
66
|
+
"test": "vitest",
|
|
65
67
|
"build": "tsc -b",
|
|
66
68
|
"check": "prettier --check .",
|
|
67
69
|
"fix": "eslint --fix . && prettier --write .",
|