Skip to content

Commit ba1a00e

Browse files
Felix-klnfisker
andauthoredFeb 1, 2023
no-empty-file: Support .jsx and .tsx extensions (#2002)
Co-authored-by: fisker Cheung <lionkay@gmail.com>
1 parent 4ada50e commit ba1a00e

File tree

4 files changed

+40
-7
lines changed

4 files changed

+40
-7
lines changed
 

‎rules/no-empty-file.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ const hasTripeSlashDirectives = comments =>
1717

1818
/** @param {import('eslint').Rule.RuleContext} context */
1919
const create = context => {
20-
const filename = context.getPhysicalFilename().toLowerCase();
20+
const filename = context.getPhysicalFilename();
2121

22-
if (!/\.(?:js|mjs|cjs|ts|mts|cts)$/.test(filename)) {
22+
if (!/\.(?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$/i.test(filename)) {
2323
return;
2424
}
2525

‎test/no-empty-file.mjs

+4-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ test.snapshot({
3535
'md',
3636
'vue',
3737
'svelte',
38-
'tsx',
3938
].map(extension => ({code: '', filename: `example.${extension}`})),
4039
...[
4140
'd.ts',
@@ -69,9 +68,11 @@ test.snapshot({
6968
].map(code => ({code, filename: 'example.js'})),
7069
...[
7170
'mjs',
72-
'cjs',
71+
'cJs',
7372
'ts',
74-
'mts',
73+
'tsx',
74+
'jsx',
75+
'MTS',
7576
'cts',
7677
].map(extension => ({code: '{}', filename: `example.${extension}`})),
7778
],

‎test/snapshots/no-empty-file.mjs.md

+34-2
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ Generated by [AVA](https://avajs.dev).
355355
> Filename
356356
357357
`␊
358-
example.cjs
358+
example.cJs
359359
`
360360

361361
> Error 1/1
@@ -387,7 +387,7 @@ Generated by [AVA](https://avajs.dev).
387387
> Filename
388388
389389
`␊
390-
example.mts
390+
example.tsx
391391
`
392392

393393
> Error 1/1
@@ -400,6 +400,38 @@ Generated by [AVA](https://avajs.dev).
400400
## Invalid #25
401401
1 | {}
402402

403+
> Filename
404+
405+
`␊
406+
example.jsx␊
407+
`
408+
409+
> Error 1/1
410+
411+
`␊
412+
> 1 | {}␊
413+
| ^^ Empty files are not allowed.␊
414+
`
415+
416+
## Invalid #26
417+
1 | {}
418+
419+
> Filename
420+
421+
`␊
422+
example.MTS␊
423+
`
424+
425+
> Error 1/1
426+
427+
`␊
428+
> 1 | {}␊
429+
| ^^ Empty files are not allowed.␊
430+
`
431+
432+
## Invalid #27
433+
1 | {}
434+
403435
> Filename
404436
405437
`␊

‎test/snapshots/no-empty-file.mjs.snap

66 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.