Skip to content

Commit d4f6943

Browse files
chore: enable eslint-plugin-perfectionist on typescript-eslint package (#9851)
1 parent 9d97f34 commit d4f6943

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

eslint.config.mjs

+2
Original file line numberDiff line numberDiff line change
@@ -570,11 +570,13 @@ export default tseslint.config(
570570
},
571571
{
572572
extends: [perfectionistPlugin.configs['recommended-alphabetical']],
573+
ignores: ['packages/typescript-eslint/src/configs/*'],
573574
files: [
574575
'packages/ast-spec/{src,tests,typings}/**/*.ts',
575576
'packages/integration-tests/{tests,tools,typing}/**/*.ts',
576577
'packages/parser/{src,tests}/**/*.ts',
577578
'packages/rule-tester/{src,tests,typings}/**/*.ts',
579+
'packages/typescript-eslint/{src,tests}/**/*.ts',
578580
'packages/utils/src/**/*.ts',
579581
'packages/visitor-keys/src/**/*.ts',
580582
'packages/website*/src/**/*.ts',

packages/typescript-eslint/src/index.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import pluginBase from '@typescript-eslint/eslint-plugin';
2-
import * as parserBase from '@typescript-eslint/parser';
31
// see the comment in config-helper.ts for why this doesn't use /ts-eslint
42
import type { TSESLint } from '@typescript-eslint/utils';
53

4+
import pluginBase from '@typescript-eslint/eslint-plugin';
5+
import * as parserBase from '@typescript-eslint/parser';
6+
67
import type { ConfigWithExtends } from './config-helper';
8+
79
import { config } from './config-helper';
810
import allConfig from './configs/all';
911
import baseConfig from './configs/base';

packages/typescript-eslint/tests/configs.test.ts

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import rules from '@typescript-eslint/eslint-plugin/use-at-your-own-risk/rules';
21
import type {
32
FlatConfig,
43
RuleRecommendation,
54
} from '@typescript-eslint/utils/ts-eslint';
65

6+
import rules from '@typescript-eslint/eslint-plugin/use-at-your-own-risk/rules';
7+
78
import plugin from '../src/index';
89

910
const RULE_NAME_PREFIX = '@typescript-eslint/';
@@ -37,14 +38,14 @@ function filterRules(
3738

3839
interface FilterAndMapRuleConfigsSettings {
3940
excludeDeprecated?: boolean;
40-
typeChecked?: 'exclude' | 'include-only';
4141
recommendations?: (RuleRecommendation | undefined)[];
42+
typeChecked?: 'exclude' | 'include-only';
4243
}
4344

4445
function filterAndMapRuleConfigs({
4546
excludeDeprecated,
46-
typeChecked,
4747
recommendations,
48+
typeChecked,
4849
}: FilterAndMapRuleConfigsSettings = {}): [string, unknown][] {
4950
let result = Object.entries(rules);
5051

@@ -149,8 +150,8 @@ describe('recommended.ts', () => {
149150
const configRules = filterRules(unfilteredConfigRules);
150151
// note: include deprecated rules so that the config doesn't change between major bumps
151152
const ruleConfigs = filterAndMapRuleConfigs({
152-
typeChecked: 'exclude',
153153
recommendations: ['recommended'],
154+
typeChecked: 'exclude',
154155
});
155156

156157
expect(entriesToObject(ruleConfigs)).toEqual(entriesToObject(configRules));
@@ -183,8 +184,8 @@ describe('recommended-type-checked-only.ts', () => {
183184
const configRules = filterRules(unfilteredConfigRules);
184185
// note: include deprecated rules so that the config doesn't change between major bumps
185186
const ruleConfigs = filterAndMapRuleConfigs({
186-
typeChecked: 'include-only',
187187
recommendations: ['recommended'],
188+
typeChecked: 'include-only',
188189
}).filter(([ruleName]) => ruleName);
189190

190191
expect(entriesToObject(ruleConfigs)).toEqual(entriesToObject(configRules));
@@ -201,8 +202,8 @@ describe('strict.ts', () => {
201202
// note: exclude deprecated rules, this config is allowed to change between minor versions
202203
const ruleConfigs = filterAndMapRuleConfigs({
203204
excludeDeprecated: true,
204-
typeChecked: 'exclude',
205205
recommendations: ['recommended', 'strict'],
206+
typeChecked: 'exclude',
206207
});
207208

208209
expect(entriesToObject(ruleConfigs)).toEqual(entriesToObject(configRules));
@@ -235,8 +236,8 @@ describe('strict-type-checked-only.ts', () => {
235236
// note: exclude deprecated rules, this config is allowed to change between minor versions
236237
const ruleConfigs = filterAndMapRuleConfigs({
237238
excludeDeprecated: true,
238-
typeChecked: 'include-only',
239239
recommendations: ['recommended', 'strict'],
240+
typeChecked: 'include-only',
240241
}).filter(([ruleName]) => ruleName);
241242

242243
expect(entriesToObject(ruleConfigs)).toEqual(entriesToObject(configRules));
@@ -252,8 +253,8 @@ describe('stylistic.ts', () => {
252253
const configRules = filterRules(unfilteredConfigRules);
253254
// note: include deprecated rules so that the config doesn't change between major bumps
254255
const ruleConfigs = filterAndMapRuleConfigs({
255-
typeChecked: 'exclude',
256256
recommendations: ['stylistic'],
257+
typeChecked: 'exclude',
257258
});
258259

259260
expect(entriesToObject(ruleConfigs)).toEqual(entriesToObject(configRules));
@@ -285,8 +286,8 @@ describe('stylistic-type-checked-only.ts', () => {
285286
const configRules = filterRules(unfilteredConfigRules);
286287
// note: include deprecated rules so that the config doesn't change between major bumps
287288
const ruleConfigs = filterAndMapRuleConfigs({
288-
typeChecked: 'include-only',
289289
recommendations: ['stylistic'],
290+
typeChecked: 'include-only',
290291
}).filter(([ruleName]) => ruleName);
291292

292293
expect(entriesToObject(ruleConfigs)).toEqual(entriesToObject(configRules));
@@ -300,23 +301,23 @@ describe('config helper', () => {
300301
expect(
301302
plugin.config({
302303
files: ['file'],
303-
rules: { rule: 'error' },
304304
ignores: ['ignored'],
305+
rules: { rule: 'error' },
305306
}),
306307
).toEqual([
307308
{
308309
files: ['file'],
309-
rules: { rule: 'error' },
310310
ignores: ['ignored'],
311+
rules: { rule: 'error' },
311312
},
312313
]);
313314
});
314315

315316
it('flattens extended configs', () => {
316317
expect(
317318
plugin.config({
318-
rules: { rule: 'error' },
319319
extends: [{ rules: { rule1: 'error' } }, { rules: { rule2: 'error' } }],
320+
rules: { rule: 'error' },
320321
}),
321322
).toEqual([
322323
{ rules: { rule1: 'error' } },
@@ -328,10 +329,10 @@ describe('config helper', () => {
328329
it('flattens extended configs with files and ignores', () => {
329330
expect(
330331
plugin.config({
332+
extends: [{ rules: { rule1: 'error' } }, { rules: { rule2: 'error' } }],
331333
files: ['common-file'],
332334
ignores: ['common-ignored'],
333335
rules: { rule: 'error' },
334-
extends: [{ rules: { rule1: 'error' } }, { rules: { rule2: 'error' } }],
335336
}),
336337
).toEqual([
337338
{

0 commit comments

Comments
 (0)