Skip to content

Commit ccbdeaa

Browse files
committed
New config: recommended just includes variable-pattern rule
Part of #249
1 parent 6a503fe commit ccbdeaa

File tree

8 files changed

+30
-10
lines changed

8 files changed

+30
-10
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ Add `no-jquery` to the plugins section of your `.eslintrc` configuration file. Y
3434
}
3535
```
3636

37-
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.
37+
## 📋 Configs
3838

39-
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.
39+
The config **`plugin:no-jquery/recommended`** includes all methods and utilies and should be used when you are aiming to remove all jQuery usage from your code.
40+
41+
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.
42+
43+
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.
4044

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

@@ -166,7 +170,7 @@ Where rules are included in the configs `slim`, `all` or `deprecated-X.X` it is
166170
* [`no-jquery/no-visibility`](docs/rules/no-visibility.md) `all`
167171
* [`no-jquery/no-when`](docs/rules/no-when.md) `all`
168172
* [`no-jquery/no-wrap`](docs/rules/no-wrap.md) `all`
169-
* [`no-jquery/variable-pattern`](docs/rules/variable-pattern.md)
173+
* [`no-jquery/variable-pattern`](docs/rules/variable-pattern.md) `recommended`
170174

171175
### ⚠️ Deprecated
172176

README.md.template

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ Add `no-jquery` to the plugins section of your `.eslintrc` configuration file. Y
3333
}
3434
```
3535

36-
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.
36+
## 📋 Configs
3737

38-
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.
38+
The config **`plugin:no-jquery/recommended`** includes all methods and utilies and should be used when you are aiming to remove all jQuery usage from your code.
39+
40+
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.
41+
42+
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.
3943

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

docs/rules/variable-pattern.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

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

5+
⚙️ This rule is enabled in `plugin:no-jquery/recommended`.
6+
57
## Rule details
68

79
❌ Examples of **incorrect** code:

src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ module.exports = {
101101
'variable-pattern': require( './rules/variable-pattern' )
102102
},
103103
configs: {
104+
recommended: {
105+
rules: {
106+
'no-jquery/variable-pattern': 'error'
107+
}
108+
},
104109
// Use this config if you are using jQuery slim build
105110
slim: {
106111
rules: {

test-self/.eslintrc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"$": "readonly"
77
},
88
"rules": {
9+
"no-implicit-globals": "off",
910
"no-undef": "off",
10-
"no-unused-expressions": "off"
11+
"no-underscore-dangle": "off",
12+
"no-unused-expressions": "off",
13+
"no-unused-vars": "off"
1114
}
1215
}

test-self/all/.eslintrc.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{
2-
"extends": "plugin:self/all",
3-
"rules": {
4-
"no-underscore-dangle": "off"
5-
}
2+
"extends": "plugin:self/all"
63
}

test-self/recommended/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "plugin:self/recommended"
3+
}

test-self/recommended/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line self/variable-pattern
2+
var foo = $( '.foo' );

0 commit comments

Comments
 (0)