Skip to content

Commit

Permalink
filename-case: Ignore $ in filenames (#1628)
Browse files Browse the repository at this point in the history
Co-authored-by: fisker Cheung <lionkay@gmail.com>
  • Loading branch information
matmilbury and fisker committed Dec 30, 2021
1 parent f6215f3 commit a43a174
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/rules/filename-case.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Enforces all linted files to have their names in a certain case style and lowerc

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`).

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

## Cases

Expand Down
2 changes: 1 addition & 1 deletion rules/filename-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const pascalCase = string => upperFirst(camelCase(string));
const numberRegex = /\d+/;
const PLACEHOLDER = '\uFFFF\uFFFF\uFFFF';
const PLACEHOLDER_REGEX = new RegExp(PLACEHOLDER, 'i');
const isIgnoredChar = char => !/^[a-z\d-_$]$/i.test(char);
const isIgnoredChar = char => !/^[a-z\d-_]$/i.test(char);
const ignoredByDefault = new Set(['index.js', 'index.mjs', 'index.cjs', 'index.ts', 'index.tsx', 'index.vue']);
const isLowerCase = string => string === string.toLowerCase();

Expand Down
11 changes: 11 additions & 0 deletions test/filename-case.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ test({
testCase('src/foo/___foo-bar.js', 'kebabCase'),
testCase('src/foo/_FooBar.js', 'pascalCase'),
testCase('src/foo/___FooBar.js', 'pascalCase'),
testCase('src/foo/$foo.js'),
testManyCases('src/foo/foo-bar.js'),
testManyCases('src/foo/foo-bar.js', {}),
testManyCases('src/foo/fooBar.js', {camelCase: true}),
Expand Down Expand Up @@ -378,6 +379,16 @@ test({
undefined,
'Filename is not in kebab case. Rename it to `[foo-bar].js`.',
),
testCase(
'src/foo/$foo_bar.js',
undefined,
'Filename is not in kebab case. Rename it to `$foo-bar.js`.',
),
testCase(
'src/foo/$fooBar.js',
undefined,
'Filename is not in kebab case. Rename it to `$foo-bar.js`.',
),
testManyCases(
'src/foo/{foo_bar}.js',
{
Expand Down

0 comments on commit a43a174

Please sign in to comment.