@culur/config-eslint 1.8.0 → 1.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/CHANGELOG.md +42 -0
- package/dist/index.cjs +181 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.mjs +178 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/index.test.ts +23 -0
- package/src/index.ts +7 -1
- package/src/overrides/imports-rules.test.ts +19 -0
- package/src/overrides/sort-package-json.test.ts +27 -0
- package/src/overrides/test-rules.test.ts +7 -0
- package/src/overrides/vue-rules.test.ts +19 -0
- package/src/rules/filename.test.ts +7 -0
- package/src/rules/filename.ts +1 -0
- package/src/rules/index.ts +6 -1
- package/src/rules/pnpm-workspace-yaml.test.ts +7 -0
- package/src/rules/pnpm-workspace-yaml.ts +189 -0
- package/src/rules/renovate-json/index.test.ts +7 -0
- package/src/rules/renovate-json/index.ts +2 -2
- package/src/rules/yaml-order.ts +19 -0
- package/src/rules/yarnrc-yml.test.ts +7 -0
- package/src/rules/{yml-yarnrc.ts → yarnrc-yml.ts} +2 -9
- package/src/types/index.test.ts +24 -0
- package/src/types/index.ts +1 -2
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { assert, it } from 'vitest';
|
|
2
|
+
import { defineOverride } from '~/types';
|
|
3
|
+
import { vueRules } from './vue-rules';
|
|
4
|
+
|
|
5
|
+
it('should be valid rule', async () => {
|
|
6
|
+
assert('partialConfig' in vueRules);
|
|
7
|
+
const [name, config] = defineOverride(vueRules);
|
|
8
|
+
|
|
9
|
+
assert(name === 'antfu/vue/rules');
|
|
10
|
+
assert(typeof config === 'object');
|
|
11
|
+
const configLocal = config;
|
|
12
|
+
|
|
13
|
+
assert(configLocal.rules);
|
|
14
|
+
|
|
15
|
+
assert.containsAllKeys(configLocal.rules, [
|
|
16
|
+
'vue/singleline-html-element-content-newline',
|
|
17
|
+
'vue/multiline-html-element-content-newline',
|
|
18
|
+
]);
|
|
19
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
2
|
+
import { expectTypeOf, it } from 'vitest';
|
|
3
|
+
import { filenameRules } from './filename';
|
|
4
|
+
|
|
5
|
+
it('should be valid rule', async () => {
|
|
6
|
+
expectTypeOf(filenameRules).toEqualTypeOf<TypedFlatConfigItem>();
|
|
7
|
+
});
|
package/src/rules/filename.ts
CHANGED
package/src/rules/index.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export { filenameRules } from './filename';
|
|
2
|
+
export {
|
|
3
|
+
pnpmWorkspaceSortKeys,
|
|
4
|
+
pnpmWorkspaceSortSequenceValues,
|
|
5
|
+
pnpmWorkspaceYamlRules,
|
|
6
|
+
} from './pnpm-workspace-yaml';
|
|
2
7
|
export { renovateJsonRules } from './renovate-json';
|
|
3
8
|
export { yamlOrder } from './yaml-order';
|
|
4
|
-
export { yarnrcYmlRules, yarnrcYmlSortKeys } from './yml
|
|
9
|
+
export { yarnrcYmlRules, yarnrcYmlSortKeys } from './yarnrc-yml';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
2
|
+
import { expectTypeOf, it } from 'vitest';
|
|
3
|
+
import { pnpmWorkspaceYamlRules } from './pnpm-workspace-yaml';
|
|
4
|
+
|
|
5
|
+
it('should be valid rule', async () => {
|
|
6
|
+
expectTypeOf(pnpmWorkspaceYamlRules).toEqualTypeOf<TypedFlatConfigItem>();
|
|
7
|
+
});
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
2
|
+
import type {
|
|
3
|
+
YamlSortKeysRecord,
|
|
4
|
+
YamlSortSequenceValuesRecord,
|
|
5
|
+
} from './yaml-order';
|
|
6
|
+
import { yamlOrder } from './yaml-order';
|
|
7
|
+
|
|
8
|
+
export const pnpmWorkspaceSortKeys = {
|
|
9
|
+
root: {
|
|
10
|
+
pathPattern: /^$/.source,
|
|
11
|
+
order: [
|
|
12
|
+
//! Monorepo
|
|
13
|
+
'packages',
|
|
14
|
+
'catalog',
|
|
15
|
+
|
|
16
|
+
//! Dependency Resolution
|
|
17
|
+
'overrides',
|
|
18
|
+
'packageExtensions',
|
|
19
|
+
'allowedDeprecatedVersions',
|
|
20
|
+
'updateConfig',
|
|
21
|
+
'supportedArchitectures',
|
|
22
|
+
'ignoredOptionalDependencies',
|
|
23
|
+
'minimumReleaseAge',
|
|
24
|
+
'minimumReleaseAgeExclude',
|
|
25
|
+
'minimumReleaseAgeIgnoreMissingTime',
|
|
26
|
+
'minimumReleaseAgeStrict',
|
|
27
|
+
'trustPolicy',
|
|
28
|
+
'trustPolicyExclude',
|
|
29
|
+
'trustPolicyIgnoreAfter',
|
|
30
|
+
'trustLockfile',
|
|
31
|
+
'blockExoticSubdeps',
|
|
32
|
+
'registries',
|
|
33
|
+
'namedRegistries',
|
|
34
|
+
|
|
35
|
+
//! Dependency Hoisting Settings
|
|
36
|
+
'hoist',
|
|
37
|
+
'hoistWorkspacePackages',
|
|
38
|
+
'hoistPattern',
|
|
39
|
+
'publicHoistPattern',
|
|
40
|
+
'shamefullyHoist',
|
|
41
|
+
|
|
42
|
+
//! Node-Modules Settings
|
|
43
|
+
'modulesDir',
|
|
44
|
+
'nodeLinker',
|
|
45
|
+
'symlink',
|
|
46
|
+
'enableModulesDir',
|
|
47
|
+
'virtualStoreDir',
|
|
48
|
+
'virtualStoreDirMaxLength',
|
|
49
|
+
'virtualStoreOnly',
|
|
50
|
+
'packageImportMethod',
|
|
51
|
+
'modulesCacheMaxAge',
|
|
52
|
+
'dlxCacheMaxAge',
|
|
53
|
+
'enableGlobalVirtualStore',
|
|
54
|
+
|
|
55
|
+
//! Store Settings
|
|
56
|
+
'storeDir',
|
|
57
|
+
'verifyStoreIntegrity',
|
|
58
|
+
'useRunningStoreServer',
|
|
59
|
+
'strictStorePkgContentCheck',
|
|
60
|
+
|
|
61
|
+
//! Network Settings
|
|
62
|
+
'httpsProxy',
|
|
63
|
+
'httpProxy',
|
|
64
|
+
'noProxy',
|
|
65
|
+
'localAddress',
|
|
66
|
+
'maxsockets',
|
|
67
|
+
'strictSsl',
|
|
68
|
+
|
|
69
|
+
//! Lockfile Settings
|
|
70
|
+
'lockfile',
|
|
71
|
+
'preferFrozenLockfile',
|
|
72
|
+
'lockfileIncludeTarballUrl',
|
|
73
|
+
'gitBranchLockfile',
|
|
74
|
+
'mergeGitBranchLockfilesBranchPattern',
|
|
75
|
+
'peersSuffixMaxLength',
|
|
76
|
+
|
|
77
|
+
//! Request Settings
|
|
78
|
+
'gitShallowHosts',
|
|
79
|
+
'networkConcurrency',
|
|
80
|
+
'fetchRetries',
|
|
81
|
+
'fetchRetryFactor',
|
|
82
|
+
'fetchRetryMintimeout',
|
|
83
|
+
'fetchRetryMaxtimeout',
|
|
84
|
+
'fetchTimeout',
|
|
85
|
+
'fetchWarnTimeoutMs',
|
|
86
|
+
'fetchMinSpeedKiBps',
|
|
87
|
+
|
|
88
|
+
//! Peer Dependency Settings
|
|
89
|
+
'autoInstallPeers',
|
|
90
|
+
'dedupePeerDependents',
|
|
91
|
+
'dedupePeers',
|
|
92
|
+
'strictPeerDependencies',
|
|
93
|
+
'resolvePeersFromWorkspaceRoot',
|
|
94
|
+
'peerDependencyRules',
|
|
95
|
+
|
|
96
|
+
//! CLI Settings
|
|
97
|
+
'[no-]color',
|
|
98
|
+
'loglevel',
|
|
99
|
+
'useBetaCli',
|
|
100
|
+
'recursiveInstall',
|
|
101
|
+
'engineStrict',
|
|
102
|
+
'npmPath',
|
|
103
|
+
'pmOnFail',
|
|
104
|
+
'ignoreWorkspaceRootCheck',
|
|
105
|
+
|
|
106
|
+
//! Build Settings
|
|
107
|
+
'ignoreScripts',
|
|
108
|
+
'childConcurrency',
|
|
109
|
+
'sideEffectsCache',
|
|
110
|
+
'sideEffectsCacheReadonly',
|
|
111
|
+
'unsafePerm',
|
|
112
|
+
'nodeOptions',
|
|
113
|
+
'verifyDepsBeforeRun',
|
|
114
|
+
'strictDepBuilds',
|
|
115
|
+
'allowBuilds',
|
|
116
|
+
'dangerouslyAllowAllBuilds',
|
|
117
|
+
|
|
118
|
+
//! Node.js Settings
|
|
119
|
+
'nodeVersion',
|
|
120
|
+
'runtimeOnFail',
|
|
121
|
+
'nodeDownloadMirrors',
|
|
122
|
+
|
|
123
|
+
//! Other Settings
|
|
124
|
+
'savePrefix',
|
|
125
|
+
'tag',
|
|
126
|
+
'globalDir',
|
|
127
|
+
'globalBinDir',
|
|
128
|
+
'npmrcAuthFile',
|
|
129
|
+
'stateDir',
|
|
130
|
+
'cacheDir',
|
|
131
|
+
'useStderr',
|
|
132
|
+
'updateNotifier',
|
|
133
|
+
'preferSymlinkedExecutables',
|
|
134
|
+
'ignoreCompatibilityDb',
|
|
135
|
+
'resolutionMode',
|
|
136
|
+
'registrySupportsTimeField',
|
|
137
|
+
'extendNodePath',
|
|
138
|
+
'deployAllFiles',
|
|
139
|
+
'dedupeDirectDeps',
|
|
140
|
+
'optimisticRepeatInstall',
|
|
141
|
+
'requiredScripts',
|
|
142
|
+
'enablePrePostScripts',
|
|
143
|
+
'scriptShell',
|
|
144
|
+
'shellEmulator',
|
|
145
|
+
'catalogMode',
|
|
146
|
+
'ci',
|
|
147
|
+
'cleanupUnusedCatalogs',
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
packages: {
|
|
151
|
+
pathPattern: `^(${[
|
|
152
|
+
'overrides',
|
|
153
|
+
'packageExtensions',
|
|
154
|
+
'allowedDeprecatedVersions',
|
|
155
|
+
'updateConfig',
|
|
156
|
+
'supportedArchitectures',
|
|
157
|
+
'registries',
|
|
158
|
+
'namedRegistries',
|
|
159
|
+
].join('|')})$`,
|
|
160
|
+
order: yamlOrder,
|
|
161
|
+
},
|
|
162
|
+
} satisfies Record<string, YamlSortKeysRecord>;
|
|
163
|
+
|
|
164
|
+
export const pnpmWorkspaceSortSequenceValues = {
|
|
165
|
+
packages: {
|
|
166
|
+
pathPattern: `^(${[
|
|
167
|
+
'ignoredOptionalDependencies',
|
|
168
|
+
'minimumReleaseAgeExclude',
|
|
169
|
+
'trustPolicyExclude',
|
|
170
|
+
].join('|')})$`,
|
|
171
|
+
order: yamlOrder,
|
|
172
|
+
},
|
|
173
|
+
} satisfies Record<string, YamlSortSequenceValuesRecord>;
|
|
174
|
+
|
|
175
|
+
export const pnpmWorkspaceYamlRules: TypedFlatConfigItem = {
|
|
176
|
+
name: 'culur/pnpm-workspace-yaml/rules',
|
|
177
|
+
files: ['pnpm-workspace.yaml'],
|
|
178
|
+
rules: {
|
|
179
|
+
'yaml/sort-keys': [
|
|
180
|
+
'error',
|
|
181
|
+
pnpmWorkspaceSortKeys.root,
|
|
182
|
+
pnpmWorkspaceSortKeys.packages,
|
|
183
|
+
],
|
|
184
|
+
'yaml/sort-sequence-values': [
|
|
185
|
+
'error',
|
|
186
|
+
pnpmWorkspaceSortSequenceValues.packages,
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
2
|
+
import { expectTypeOf, it } from 'vitest';
|
|
3
|
+
import { renovateJsonRules } from '.';
|
|
4
|
+
|
|
5
|
+
it('should be valid rule', async () => {
|
|
6
|
+
expectTypeOf(renovateJsonRules).toEqualTypeOf<TypedFlatConfigItem>();
|
|
7
|
+
});
|
|
@@ -20,11 +20,11 @@ export const renovateJsonRules: TypedFlatConfigItem = {
|
|
|
20
20
|
'jsonc/sort-keys': [
|
|
21
21
|
'error',
|
|
22
22
|
{
|
|
23
|
-
pathPattern:
|
|
23
|
+
pathPattern: /^$/.source,
|
|
24
24
|
order: rootOrder,
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
|
-
pathPattern:
|
|
27
|
+
pathPattern: /^packageRules\[\d+\]$/.source,
|
|
28
28
|
order: packageRuleOrder,
|
|
29
29
|
},
|
|
30
30
|
],
|
package/src/rules/yaml-order.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
|
+
import type { Rules } from '@antfu/eslint-config';
|
|
2
|
+
import type { Linter } from 'eslint';
|
|
3
|
+
|
|
1
4
|
export const yamlOrder = {
|
|
2
5
|
type: 'asc',
|
|
3
6
|
caseSensitive: false,
|
|
4
7
|
natural: true,
|
|
5
8
|
} as const;
|
|
9
|
+
|
|
10
|
+
export type YamlSortKeys =
|
|
11
|
+
NonNullable<Rules['yaml/sort-keys']> extends Linter.RuleEntry<infer F>
|
|
12
|
+
? F
|
|
13
|
+
: never;
|
|
14
|
+
|
|
15
|
+
export type YamlSortKeysRecord = YamlSortKeys[0];
|
|
16
|
+
|
|
17
|
+
export type YamlSortSequenceValues =
|
|
18
|
+
NonNullable<Rules['yaml/sort-sequence-values']> extends Linter.RuleEntry<
|
|
19
|
+
infer F
|
|
20
|
+
>
|
|
21
|
+
? F
|
|
22
|
+
: never;
|
|
23
|
+
|
|
24
|
+
export type YamlSortSequenceValuesRecord = YamlSortSequenceValues[0];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
2
|
+
import { expectTypeOf, it } from 'vitest';
|
|
3
|
+
import { yarnrcYmlRules } from './yarnrc-yml';
|
|
4
|
+
|
|
5
|
+
it('should be valid rule', async () => {
|
|
6
|
+
expectTypeOf(yarnrcYmlRules).toEqualTypeOf<TypedFlatConfigItem>();
|
|
7
|
+
});
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
2
|
+
import type { YamlSortKeysRecord } from './yaml-order';
|
|
3
3
|
import { yamlOrder } from './yaml-order';
|
|
4
4
|
|
|
5
|
-
type YamlSortKeys =
|
|
6
|
-
NonNullable<Rules['yaml/sort-keys']> extends Linter.RuleEntry<infer F>
|
|
7
|
-
? F
|
|
8
|
-
: never;
|
|
9
|
-
|
|
10
|
-
type YamlSortKeysRecord = YamlSortKeys[0];
|
|
11
|
-
|
|
12
5
|
export const yarnrcYmlSortKeys = {
|
|
13
6
|
packageExtensions: {
|
|
14
7
|
packages: {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Awaitable, TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
2
|
+
import type { OverrideConfig } from '.';
|
|
3
|
+
import { expect, expectTypeOf, it } from 'vitest';
|
|
4
|
+
import { defineOverride } from '.';
|
|
5
|
+
|
|
6
|
+
it.each<OverrideConfig>([
|
|
7
|
+
{
|
|
8
|
+
name: 'object',
|
|
9
|
+
partialConfig: { rules: {} },
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: 'function',
|
|
13
|
+
entireConfig: () => ({ rules: {} }),
|
|
14
|
+
},
|
|
15
|
+
])('config is $name', options => {
|
|
16
|
+
const overrideParameter = defineOverride(options);
|
|
17
|
+
|
|
18
|
+
const [name, config] = overrideParameter;
|
|
19
|
+
|
|
20
|
+
expect(typeof name).toEqual('string');
|
|
21
|
+
expectTypeOf(config).toEqualTypeOf<
|
|
22
|
+
TypedFlatConfigItem | (() => Awaitable<TypedFlatConfigItem>)
|
|
23
|
+
>();
|
|
24
|
+
});
|
package/src/types/index.ts
CHANGED