Skip to content

Commit

Permalink
Add RegExp documentation for no-extraneous-dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
knpwrs committed Aug 27, 2016
1 parent d9b9730 commit c739798
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/rules/no-extraneous-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ You can set the options like this:
"import/no-extraneous-dependencies": ["error", {"devDependencies": false, "optionalDependencies": false, "peerDependencies": false}]
```

You can also use regular expressions instead of literal booleans:

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

If you are using JavaScript configuration (e.g., `.eslintrc.js`), then you can use a RegExp literal instead of a string:

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

When using a regular expression the result of running [`test`] against the name of the file being linted is used as the boolean value. For example, the above configurations will allow the import of `devDependencies` in files whose names include `test` or `spec`.

## Rule Details

Expand Down Expand Up @@ -86,3 +99,5 @@ import react from 'react';
## When Not To Use It

If you do not have a `package.json` file in your project.

[`test`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test "RegExp.prototype.test"

0 comments on commit c739798

Please sign in to comment.