Skip to content

Commit

Permalink
Only support arrays of globs.
Browse files Browse the repository at this point in the history
  • Loading branch information
knpwrs committed Aug 30, 2016
1 parent 8d16c08 commit 505aea8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
8 changes: 1 addition & 7 deletions docs/rules/no-extraneous-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ You can set the options like this:
"import/no-extraneous-dependencies": ["error", {"devDependencies": false, "optionalDependencies": false, "peerDependencies": false}]
```

You can also use globs instead of literal booleans:

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

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:
You can also use an array of globs instead of literal booleans:

```js
"import/no-extraneous-dependencies": ["error", {"devDependencies": ['*.test.js', '*.spec.js']}]
Expand Down
8 changes: 4 additions & 4 deletions src/rules/no-extraneous-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function testConfig(config, filename) {
return config
}
// Account for the possibility of an array for multiple configuration
return [].concat(config).some(c => minimatch(filename, c))
return config.some(c => minimatch(filename, c))
}

module.exports = function (context) {
Expand Down Expand Up @@ -113,9 +113,9 @@ module.exports.schema = [
{
'type': 'object',
'properties': {
'devDependencies': { 'type': ['boolean', 'string', 'array'] },
'optionalDependencies': { 'type': ['boolean', 'string', 'array'] },
'peerDependencies': { 'type': ['boolean', 'string', 'array'] },
'devDependencies': { 'type': ['boolean', 'array'] },
'optionalDependencies': { 'type': ['boolean', 'array'] },
'peerDependencies': { 'type': ['boolean', 'array'] },
},
'additionalProperties': false,
},
Expand Down
4 changes: 2 additions & 2 deletions tests/src/rules/no-extraneous-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ruleTester.run('no-extraneous-dependencies', rule, {
}),
test({
code: 'import chai from "chai"',
options: [{devDependencies: '*.spec.js'}],
options: [{devDependencies: ['*.spec.js']}],
filename: 'foo.spec.js',
}),
test({
Expand Down Expand Up @@ -101,7 +101,7 @@ ruleTester.run('no-extraneous-dependencies', rule, {
}),
test({
code: 'import chai from "chai"',
options: [{devDependencies: '*.test.js'}],
options: [{devDependencies: ['*.test.js']}],
filename: 'foo.tes.js',
errors: [{
ruleId: 'no-extraneous-dependencies',
Expand Down

0 comments on commit 505aea8

Please sign in to comment.