Skip to content

Commit 6792093

Browse files
committed
🐛 fix duplicate extensions
1 parent c3c4062 commit 6792093

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

packages/create-configs/src/steps/scripts.spec.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,32 @@ import { _generate_lint_script } from './scripts.js';
33

44
describe('scripts', () => {
55
describe(_generate_lint_script.name, () => {
6-
it(`should create lint scripts`, () => {
6+
it(`should create ts lint scripts`, () => {
77
const output = _generate_lint_script({
88
builder: 'esbuild',
99
languages: ['ts'],
1010
technologies: ['react'],
1111
});
1212
expect(output.lint).toMatch(/concurrently.+"npm:lint:\*"/u);
13-
expect(output['lint:js']).toMatch(/^eslint/u);
13+
expect(output['lint:js']).toMatch(/^eslint /u);
14+
expect(output['lint:js']).toMatch(/ --ext /u);
15+
expect(
16+
output['lint:js']?.match(/--ext (\S+)\b/u)?.[1]?.split(','),
17+
).toEqual(['ts', 'tsx', 'json']);
18+
});
19+
20+
it(`should create ts & js lint scripts`, () => {
21+
const output = _generate_lint_script({
22+
builder: 'esbuild',
23+
languages: ['ts', 'js'],
24+
technologies: [],
25+
});
26+
expect(output.lint).toMatch(/concurrently.+"npm:lint:\*"/u);
27+
expect(output['lint:js']).toMatch(/^eslint /u);
28+
expect(output['lint:js']).toMatch(/ --ext /u);
29+
expect(
30+
output['lint:js']?.match(/--ext (\S+)\b/u)?.[1]?.split(','),
31+
).toEqual(['js', 'ts', 'json']);
1432
});
1533
});
1634
});

packages/create-configs/src/steps/scripts.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,14 @@ export function _generate_lint_script({
9191
...scripts,
9292
'lint:js': `eslint . --ext ${languages
9393
.filter((l) => ['js', 'ts'].includes(l))
94-
.reduce<string[]>((extensions, ext) => {
95-
return [
94+
.reduce<string[]>(
95+
(extensions, ext) => [
96+
ext,
97+
...(technologies.includes('react') ? [`${ext}x`] : []),
9698
...extensions,
97-
...(technologies.includes('react')
98-
? [ext]
99-
: [ext, `${ext}x`]),
100-
'json',
101-
];
102-
}, [])
99+
],
100+
['json'],
101+
)
103102
.join(',')} --cache`,
104103
};
105104
case 'stylelint':

0 commit comments

Comments
 (0)