Skip to content

Commit

Permalink
fix!: correct camelcase rule schema for allow option (#18232)
Browse files Browse the repository at this point in the history
fix: correct json schema of camelcase to allow array of string
  • Loading branch information
eMerzh committed Apr 1, 2024
1 parent 12f5746 commit b7cf3bd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
9 changes: 9 additions & 0 deletions docs/src/use/migrate-to-9.0.0.md
Expand Up @@ -36,6 +36,7 @@ The lists below are ordered roughly by the number of users each change is expect
* [`no-inner-declarations` has a new default behavior with a new option](#no-inner-declarations)
* [`no-unused-vars` now defaults `caughtErrors` to `"all"`](#no-unused-vars)
* [`no-useless-computed-key` flags unnecessary computed member names in classes by default](#no-useless-computed-key)
* [`camelcase` allow option only accepts an array of strings](#camelcase)

### Breaking changes for plugin developers

Expand Down Expand Up @@ -434,6 +435,14 @@ class SomeClass {

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

## <a name="camelcase"></a> `camelcase` allow option only accepts an array of strings

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.

**To address:** If ESLint reports invalid configuration for this rule, update your configuration.

**Related issue(s):** [#18232](https://github.com/eslint/eslint/pull/18232)

## <a name="removed-context-methods"></a> Removed multiple `context` methods

ESLint v9.0.0 removes multiple deprecated methods from the `context` object and moves them onto the `SourceCode` object:
Expand Down
8 changes: 3 additions & 5 deletions lib/rules/camelcase.js
Expand Up @@ -47,11 +47,9 @@ module.exports = {
},
allow: {
type: "array",
items: [
{
type: "string"
}
],
items: {
type: "string"
},
minItems: 0,
uniqueItems: true
}
Expand Down
12 changes: 12 additions & 0 deletions tests/lib/rules/camelcase.js
Expand Up @@ -337,6 +337,18 @@ ruleTester.run("camelcase", rule, {
code: "__option_foo__ = 0;",
options: [{ allow: ["__option_foo__"] }]
},
{
code: "__option_foo__ = 0; user_id = 0; foo = 1",
options: [{ allow: ["__option_foo__", "_id$"] }]
},
{
code: "fo_o = 0;",
options: [{ allow: ["__option_foo__", "fo_o"] }]
},
{
code: "user = 0;",
options: [{ allow: [] }]
},
{
code: "foo = { [computedBar]: 0 };",
options: [{ ignoreDestructuring: true }],
Expand Down

0 comments on commit b7cf3bd

Please sign in to comment.