Skip to content

Commit b7cf3bd

Browse files
authored
fix!: correct camelcase rule schema for allow option (#18232)
fix: correct json schema of camelcase to allow array of string
1 parent 12f5746 commit b7cf3bd

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

‎docs/src/use/migrate-to-9.0.0.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ The lists below are ordered roughly by the number of users each change is expect
3636
* [`no-inner-declarations` has a new default behavior with a new option](#no-inner-declarations)
3737
* [`no-unused-vars` now defaults `caughtErrors` to `"all"`](#no-unused-vars)
3838
* [`no-useless-computed-key` flags unnecessary computed member names in classes by default](#no-useless-computed-key)
39+
* [`camelcase` allow option only accepts an array of strings](#camelcase)
3940

4041
### Breaking changes for plugin developers
4142

@@ -434,6 +435,14 @@ class SomeClass {
434435

435436
**Related issue(s):** [#18042](https://github.com/eslint/eslint/issues/18042)
436437

438+
## <a name="camelcase"></a> `camelcase` allow option only accepts an array of strings
439+
440+
Previously the camelcase rule didn't enforce the `allow` option to be an array of strings. In ESLint v9.0.0, the `allow` option now only accepts an array of strings.
441+
442+
**To address:** If ESLint reports invalid configuration for this rule, update your configuration.
443+
444+
**Related issue(s):** [#18232](https://github.com/eslint/eslint/pull/18232)
445+
437446
## <a name="removed-context-methods"></a> Removed multiple `context` methods
438447

439448
ESLint v9.0.0 removes multiple deprecated methods from the `context` object and moves them onto the `SourceCode` object:

‎lib/rules/camelcase.js‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ module.exports = {
4747
},
4848
allow: {
4949
type: "array",
50-
items: [
51-
{
52-
type: "string"
53-
}
54-
],
50+
items: {
51+
type: "string"
52+
},
5553
minItems: 0,
5654
uniqueItems: true
5755
}

‎tests/lib/rules/camelcase.js‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,18 @@ ruleTester.run("camelcase", rule, {
337337
code: "__option_foo__ = 0;",
338338
options: [{ allow: ["__option_foo__"] }]
339339
},
340+
{
341+
code: "__option_foo__ = 0; user_id = 0; foo = 1",
342+
options: [{ allow: ["__option_foo__", "_id$"] }]
343+
},
344+
{
345+
code: "fo_o = 0;",
346+
options: [{ allow: ["__option_foo__", "fo_o"] }]
347+
},
348+
{
349+
code: "user = 0;",
350+
options: [{ allow: [] }]
351+
},
340352
{
341353
code: "foo = { [computedBar]: 0 };",
342354
options: [{ ignoreDestructuring: true }],

0 commit comments

Comments
 (0)