Skip to content

Commit 505aea8

Browse files
committed
Only support arrays of globs.
1 parent 8d16c08 commit 505aea8

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

docs/rules/no-extraneous-dependencies.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ You can set the options like this:
1919
"import/no-extraneous-dependencies": ["error", {"devDependencies": false, "optionalDependencies": false, "peerDependencies": false}]
2020
```
2121

22-
You can also use globs instead of literal booleans:
23-
24-
```js
25-
"import/no-extraneous-dependencies": ["error", {"devDependencies": "*.test.js"}]
26-
```
27-
28-
When using a glob, the setting will be activated if the name of the file being linted matches the given glob. In addition, you can use an array to specify multiple globs:
22+
You can also use an array of globs instead of literal booleans:
2923

3024
```js
3125
"import/no-extraneous-dependencies": ["error", {"devDependencies": ['*.test.js', '*.spec.js']}]

src/rules/no-extraneous-dependencies.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function testConfig(config, filename) {
7878
return config
7979
}
8080
// Account for the possibility of an array for multiple configuration
81-
return [].concat(config).some(c => minimatch(filename, c))
81+
return config.some(c => minimatch(filename, c))
8282
}
8383

8484
module.exports = function (context) {
@@ -113,9 +113,9 @@ module.exports.schema = [
113113
{
114114
'type': 'object',
115115
'properties': {
116-
'devDependencies': { 'type': ['boolean', 'string', 'array'] },
117-
'optionalDependencies': { 'type': ['boolean', 'string', 'array'] },
118-
'peerDependencies': { 'type': ['boolean', 'string', 'array'] },
116+
'devDependencies': { 'type': ['boolean', 'array'] },
117+
'optionalDependencies': { 'type': ['boolean', 'array'] },
118+
'peerDependencies': { 'type': ['boolean', 'array'] },
119119
},
120120
'additionalProperties': false,
121121
},

tests/src/rules/no-extraneous-dependencies.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ruleTester.run('no-extraneous-dependencies', rule, {
3737
}),
3838
test({
3939
code: 'import chai from "chai"',
40-
options: [{devDependencies: '*.spec.js'}],
40+
options: [{devDependencies: ['*.spec.js']}],
4141
filename: 'foo.spec.js',
4242
}),
4343
test({
@@ -101,7 +101,7 @@ ruleTester.run('no-extraneous-dependencies', rule, {
101101
}),
102102
test({
103103
code: 'import chai from "chai"',
104-
options: [{devDependencies: '*.test.js'}],
104+
options: [{devDependencies: ['*.test.js']}],
105105
filename: 'foo.tes.js',
106106
errors: [{
107107
ruleId: 'no-extraneous-dependencies',

0 commit comments

Comments
 (0)