Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitabcfc3b

Browse files
authored
Merge pull request#584 from github/gracepark/filenames-default-update
Update filenames default since it is now in our repo
2 parents5bb75fb +2b0173c commitabcfc3b

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

‎README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ export default [
5656
```
5757

5858
>[!NOTE]
59-
>If you configured the`filenames/match-regex` rule, please note we have adapted the match regex rule into`eslint-plugin-github` as the original`eslint-filenames-plugin` is no longer maintained and needed an ESLint v9/flat config update. Please update the name to`github/filenames-match-regex` and keep the same configuration. Note, that the default rule is camelCase with one hump. If there are multiple humps like`camelCaseTest.js`, this default rule will error out. Here's an example for this rule with custom configuration:
59+
>If you configured the`filenames/match-regex` rule, please note we have adapted the match regex rule into`eslint-plugin-github` as the original`eslint-filenames-plugin` is no longer maintained and needed a flat config support update.
60+
>
61+
>Please update the name to`github/filenames-match-regex`, and note, the default rule is kebab case or camelCase with one hump. For custom configuration, such as matching for camelCase regex, here's an example:
6062
>
61-
>`'github/filenames-match-regex': ['error', '^[a-z0-9-]+(.[a-z0-9-]+)?$']`
63+
>`'github/filenames-match-regex': ['error', '^([a-z0-9]+)([A-Z][a-z0-9]+)*$'],`
6264
6365
The available configs are:
6466

‎docs/rules/filenames-match-regex.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,38 @@
44

55
##Rule Details
66

7-
Rule to ensure that filenames match a convention, with a default of camelCase forESLint v9+.
7+
Rule to ensure that filenames match a convention, with a default ofkebab case orcamelCasewith one humpforflat config.
88

99
👎 Examples of**incorrect** filename for this default rule:
1010

11-
`file-name.js`
11+
-`fileNameRule.js`
1212

1313
👍 Examples of**correct** code for this rule:
1414

15-
`fileName.js`
15+
-`fileName.js`
16+
-`file-name.js`
1617

1718
##Options
1819

19-
regex - Regex to match the filename structure. Defaults to camelCase.
20+
regex - Regex to match the filename structure. Defaults tokebab case orcamelCase with one hump.
2021

22+
Default:
23+
24+
```json
25+
{
26+
"filenames-match-regex": [
27+
"error"
28+
]
29+
}
30+
```
31+
32+
If you want to add custom regex such as matching all camelCase, add the regex as a string. For example, for camelCase it would look like:
2133

2234
```json
2335
{
2436
"filenames-match-regex": [
2537
"error",
26-
"^[a-z0-9-]+(.[a-z0-9-]+)?$"
38+
"^([a-z0-9]+)([A-Z][a-z0-9]+)*$"
2739
]
2840
}
2941
```

‎lib/configs/flat/recommended.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = {
3232
'eslintComments/no-unused-disable':'error',
3333
'eslintComments/no-unused-enable':'error',
3434
'eslintComments/no-use':['error',{allow:['eslint','eslint-disable-next-line','eslint-env','globals']}],
35-
'github/filenames-match-regex':['error','^[a-z0-9-]+(.[a-z0-9-]+)?$'],
35+
'github/filenames-match-regex':'error',
3636
'func-style':['error','declaration',{allowArrowFunctions:true}],
3737
'github/array-foreach':'error',
3838
'github/no-implicit-buggy-globals':'error',

‎lib/rules/filenames-match-regex.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ module.exports = {
2525
},
2626

2727
create(context){
28-
constdefaultRegexp=/^([a-z0-9]+)([A-Z][a-z0-9]+)*$/g
28+
// GitHub's default is kebab case or one hump camel case
29+
constdefaultRegexp=/^[a-z0-9-]+(.[a-z0-9-]+)?$/
2930
constconventionRegexp=context.options[0] ?newRegExp(context.options[0]) :defaultRegexp
3031
constignoreExporting=context.options[1] ?context.options[1] :false
3132

‎test-examples/flat/eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default [
1313
'github/no-then':'error',
1414
'github/no-blur':'error',
1515
'github/async-preventdefault':'error',
16+
'github/filenames-match-regex':['error','^([a-z0-9]+)([A-Z][a-z0-9]+)*$'],
1617
},
1718
},
1819
]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp