8000 update filenames default since it is now in our repo · github/eslint-plugin-github@1373fa2 · GitHub
[go: up one dir, main page]

Skip to content

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

Appearance settings

Commit 1373fa2

Browse files
committed
update filenames default since it is now in our repo
1 parent 5bb75fb commit 1373fa2

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`. Please 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 for ESLint v9+.
7+
Rule to ensure that filenames match a convention, with a default of kebab case or camelCase with one hump for flat 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 to kebab case or camelCase with one hump.
2021

22+
Default:
2123

2224
```json
2325
{
2426
"filenames-match-regex": [
2527
"error",
26-
"^[a-z0-9-]+(.[a-z0-9-]+)?$"
28+
]
29+
}
30+
```
31+
32+
If you want to add custom regex such as matching all camelCase, this would be the option:
33+
34+
```json
35+
{
36+
'filenames-match-regex': [
37+
'error',
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-
const defaultRegexp = /^([a-z0-9]+)([A-Z][a-z0-9]+)*$/g
28+
// GitHub's default is kebab case or one hump camel case
29+
const defaultRegexp = /^[a-z0-9-]+(.[a-z0-9-]+)?$/
2930
const conventionRegexp = context.options[0] ? new RegExp(context.options[0]) : defaultRegexp
3031
const ignoreExporting = 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)
0