Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New config: recommended just includes variable-pattern rule #257

Merged
merged 2 commits into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ Add `no-jquery` to the plugins section of your `.eslintrc` configuration file. Y
}
```

The config `plugin:no-jquery/deprecated` includes all known deprecated and removed code, and is updated as new releases of jQuery come out. You can instead use configs targeting specific versions of jQuery if you know the environment in which your code will operate. There is a config for jQuery 3.5.x+ environments (`deprecated-3.5`), and configs for other minor releases that include deprecations (`deprecated-3.4`, `deprecated-1.10` etc.). Deprecation configs are cumulative, so they include all the rules for jQuery versions below them.
## 📋 Configs

The config `plugin:no-jquery/all` includes all methods and utilies and should be used when you are aiming to remove all jQuery usage from your code.
The config **`plugin:no-jquery/recommended`** includes the recommended rule [`no-jquery/variable-pattern`](docs/rules/variable-pattern.md) which is required for method rules to work correctly.

The config **`plugin:no-jquery/deprecated`** includes all known deprecated and removed code, and is updated as new releases of jQuery come out. You can instead use configs targeting specific versions of jQuery if you know the environment in which your code will operate. There is a config for jQuery 3.5.x+ environments (`deprecated-3.5`), and configs for other minor releases that include deprecations (`deprecated-3.4`, `deprecated-1.10` etc.). Deprecation configs are cumulative, so they include all the rules for jQuery versions below them.

The config **`plugin:no-jquery/all`** includes all methods and utilies and should be used when you are aiming to remove all jQuery usage from your code.

Alternatively, you can pick out rules individually (see below).

Expand Down Expand Up @@ -75,7 +79,7 @@ The following global settings can be used under the `no-jquery` property to conf

## 📖 Rules

Where rules are included in the configs `slim`, `all` or `deprecated-X.X` it is indicated below. Where rules are included with options this is indicated with a `†`.
Where rules are included in the configs `recommended`, `slim`, `all` or `deprecated-X.X` it is indicated below. Where rules are included with options this is indicated with a `†`.
* [`no-jquery/no-ajax`](docs/rules/no-ajax.md) `slim`, `all`
* [`no-jquery/no-ajax-events`](docs/rules/no-ajax-events.md) `slim`
* [`no-jquery/no-and-self`](docs/rules/no-and-self.md) `1.8`
Expand Down Expand Up @@ -166,7 +170,7 @@ Where rules are included in the configs `slim`, `all` or `deprecated-X.X` it is
* [`no-jquery/no-visibility`](docs/rules/no-visibility.md) `all`
* [`no-jquery/no-when`](docs/rules/no-when.md) `all`
* [`no-jquery/no-wrap`](docs/rules/no-wrap.md) `all`
* [`no-jquery/variable-pattern`](docs/rules/variable-pattern.md)
* [`no-jquery/variable-pattern`](docs/rules/variable-pattern.md) `recommended`

### ⚠️ Deprecated

Expand Down
10 changes: 7 additions & 3 deletions README.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ Add `no-jquery` to the plugins section of your `.eslintrc` configuration file. Y
}
```

The config `plugin:no-jquery/deprecated` includes all known deprecated and removed code, and is updated as new releases of jQuery come out. You can instead use configs targeting specific versions of jQuery if you know the environment in which your code will operate. There is a config for jQuery 3.5.x+ environments (`deprecated-3.5`), and configs for other minor releases that include deprecations (`deprecated-3.4`, `deprecated-1.10` etc.). Deprecation configs are cumulative, so they include all the rules for jQuery versions below them.
## 📋 Configs

The config `plugin:no-jquery/all` includes all methods and utilies and should be used when you are aiming to remove all jQuery usage from your code.
The config **`plugin:no-jquery/recommended`** includes the recommended rule [`no-jquery/variable-pattern`](docs/rules/variable-pattern.md) which is required for method rules to work correctly.

The config **`plugin:no-jquery/deprecated`** includes all known deprecated and removed code, and is updated as new releases of jQuery come out. You can instead use configs targeting specific versions of jQuery if you know the environment in which your code will operate. There is a config for jQuery 3.5.x+ environments (`deprecated-3.5`), and configs for other minor releases that include deprecations (`deprecated-3.4`, `deprecated-1.10` etc.). Deprecation configs are cumulative, so they include all the rules for jQuery versions below them.

The config **`plugin:no-jquery/all`** includes all methods and utilies and should be used when you are aiming to remove all jQuery usage from your code.

Alternatively, you can pick out rules individually (see below).

Expand Down Expand Up @@ -74,7 +78,7 @@ The following global settings can be used under the `no-jquery` property to conf

## 📖 Rules

Where rules are included in the configs `slim`, `all` or `deprecated-X.X` it is indicated below. Where rules are included with options this is indicated with a `†`.
Where rules are included in the configs `recommended`, `slim`, `all` or `deprecated-X.X` it is indicated below. Where rules are included with options this is indicated with a `†`.
<!-- rules -->

### ⚠️ Deprecated
Expand Down
2 changes: 2 additions & 0 deletions docs/rules/variable-pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Disallows variable names which don't match `variablePattern` in settings (by default a `$`-prefix).

⚙️ This rule is enabled in `plugin:no-jquery/recommended`.

## Rule details

❌ Examples of **incorrect** code:
Expand Down
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ module.exports = {
'variable-pattern': require( './rules/variable-pattern' )
},
configs: {
recommended: {
rules: {
'no-jquery/variable-pattern': 'error'
}
},
// Use this config if you are using jQuery slim build
slim: {
rules: {
Expand Down
5 changes: 4 additions & 1 deletion test-self/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"$": "readonly"
},
"rules": {
"no-implicit-globals": "off",
"no-undef": "off",
"no-unused-expressions": "off"
"no-underscore-dangle": "off",
"no-unused-expressions": "off",
"no-unused-vars": "off"
}
}
5 changes: 1 addition & 4 deletions test-self/all/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"extends": "plugin:self/all",
"rules": {
"no-underscore-dangle": "off"
}
"extends": "plugin:self/all"
}
3 changes: 3 additions & 0 deletions test-self/recommended/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "plugin:self/recommended"
}
2 changes: 2 additions & 0 deletions test-self/recommended/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line self/variable-pattern
var foo = $( '.foo' );