Skip to content

Commit a43a174

Browse files
matmilburyfisker
andauthored
filename-case: Ignore $ in filenames (#1628)
Co-authored-by: fisker Cheung <[email protected]>
1 parent f6215f3 commit a43a174

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

docs/rules/filename-case.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Enforces all linted files to have their names in a certain case style and lowerc
66

77
Files named `index.js`, `index.mjs`, `index.cjs`, `index.ts`, `index.tsx`, `index.vue` are ignored as they can't change case (Only a problem with `pascalCase`).
88

9-
Characters in the filename except `a-z`, `A-Z`, `0-9`, `-`, `_` and `$` are ignored.
9+
Characters in the filename except `a-z`, `A-Z`, `0-9`, `-`, and `_` are ignored.
1010

1111
## Cases
1212

rules/filename-case.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const pascalCase = string => upperFirst(camelCase(string));
1414
const numberRegex = /\d+/;
1515
const PLACEHOLDER = '\uFFFF\uFFFF\uFFFF';
1616
const PLACEHOLDER_REGEX = new RegExp(PLACEHOLDER, 'i');
17-
const isIgnoredChar = char => !/^[a-z\d-_$]$/i.test(char);
17+
const isIgnoredChar = char => !/^[a-z\d-_]$/i.test(char);
1818
const ignoredByDefault = new Set(['index.js', 'index.mjs', 'index.cjs', 'index.ts', 'index.tsx', 'index.vue']);
1919
const isLowerCase = string => string === string.toLowerCase();
2020

test/filename-case.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ test({
7979
testCase('src/foo/___foo-bar.js', 'kebabCase'),
8080
testCase('src/foo/_FooBar.js', 'pascalCase'),
8181
testCase('src/foo/___FooBar.js', 'pascalCase'),
82+
testCase('src/foo/$foo.js'),
8283
testManyCases('src/foo/foo-bar.js'),
8384
testManyCases('src/foo/foo-bar.js', {}),
8485
testManyCases('src/foo/fooBar.js', {camelCase: true}),
@@ -378,6 +379,16 @@ test({
378379
undefined,
379380
'Filename is not in kebab case. Rename it to `[foo-bar].js`.',
380381
),
382+
testCase(
383+
'src/foo/$foo_bar.js',
384+
undefined,
385+
'Filename is not in kebab case. Rename it to `$foo-bar.js`.',
386+
),
387+
testCase(
388+
'src/foo/$fooBar.js',
389+
undefined,
390+
'Filename is not in kebab case. Rename it to `$foo-bar.js`.',
391+
),
381392
testManyCases(
382393
'src/foo/{foo_bar}.js',
383394
{

0 commit comments

Comments
 (0)