Skip to content

Commit

Permalink
feat: Enable test rules by glob pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Jul 10, 2019
1 parent 6efa5a3 commit 63c023c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
17 changes: 0 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,6 @@ In your `package.json`, add a `lint` script and run it as `posttest`:

The base rules use the `eslint-plugin-import` to resolve imports. Although it's possible to define [custom resolvers](https://github.com/benmosher/eslint-plugin-import#resolvers), it's highly discouraged to deviate from the common Node/webpack resolving algorithm. Other tools like linters and intellisense don't work reliably when you change the resolver.

---

### [`peerigon/tests`](tests.js)

Special rules for tests, like allowing deeper function nesting and function inlining.
Create a `.eslintrc.json` file inside your `test` folder with these contents:

```js
{
"extends": [
"peerigon/tests"
]
}
```

Do not add `"root": true` here since we want to *extend* our project config.

### [`peerigon/node`](node.js)

Special rules for Node.js >= 8.0.0 environments:
Expand Down
10 changes: 10 additions & 0 deletions base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

const options = require("./options.js");
const globPatterns = require("./globPatterns.js");
const tests = require("./tests.js");

module.exports = {
parser: "babel-eslint",
Expand All @@ -28,6 +29,15 @@ module.exports = {
"plugin:array-func/recommended",
"plugin:promise/recommended"
],
// TODO: With ESLint 6 you can pass an array of files. Change this once we've updated.
overrides: globPatterns.tests.map(testGlobPattern =>
Object.assign(
{
files: testGlobPattern,
},
tests
)
),
rules: {
/* eslint-enable sort-keys */
"accessor-pairs": [
Expand Down

0 comments on commit 63c023c

Please sign in to comment.