Skip to content

Commit 6a6706e

Browse files
Henrinovemberborn
authored andcommitted
Add support for ava.config.js (#192)
Adds support for checking the `ava.config.js` when there is no `ava` config inside `package.json`. This uses the `esm` module for parsing the config file. Fixes #191 Co-authored-by: Mark Wubben <[email protected]>
1 parent bd307de commit 6a6706e

File tree

23 files changed

+143
-6
lines changed

23 files changed

+143
-6
lines changed

docs/rules/no-ignored-test-files.md

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

33
Translations: [Français](https://github.com/avajs/ava-docs/blob/master/fr_FR/related/eslint-plugin-ava/docs/rules/no-ignored-test-files.md)
44

5-
When searching for tests, AVA ignores files contained in `node_modules` or folders named `fixtures` or `helpers`. By default, it will search in `test.js test-*.js test/**/*.js **/__tests__/**/*.js **/*.test.js`, which you can override by specifying a path when launching AVA or in the [AVA configuration in the `package.json` file](https://github.com/sindresorhus/ava#configuration).
5+
When searching for tests, AVA ignores files contained in `node_modules` or folders named `fixtures` or `helpers`. By default, it will search in `test.js test-*.js test/**/*.js **/__tests__/**/*.js **/*.test.js`, which you can override by specifying a path when launching AVA or in the [AVA configuration in the `package.json` or `ava.config.js` files](https://github.com/sindresorhus/ava#configuration).
66

77
This rule will verify that files which create tests are in the searched files and not in ignored folders. It will consider the root of the project to be the closest folder containing a `package.json` file, and will not do anything if it can't find one. Test files in `node_modules` will not be linted as they are ignored by ESLint.
88

@@ -85,7 +85,7 @@ test('foo', t => {
8585

8686
This rule supports the following options:
8787

88-
`files`: An array of strings representing the files glob that AVA will use to find test files. Overrides the default and the configuration found in the `package.json` file.
88+
`files`: An array of strings representing the files glob that AVA will use to find test files. Overrides the default and the configuration found in the `package.json` or `ava.config.js` files.
8989

9090
You can set the options like this:
9191

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@
3333
"arrify": "^1.0.1",
3434
"deep-strict-equal": "^0.2.0",
3535
"enhance-visitors": "^1.0.0",
36+
"esm": "^3.0.69",
3637
"espree": "^4.0.0",
3738
"espurify": "^1.5.0",
3839
"import-modules": "^1.1.0",
40+
"is-plain-object": "^2.0.4",
3941
"multimatch": "^2.1.0",
4042
"pkg-up": "^2.0.0"
4143
},
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Config {}
2+
3+
export default () => new Config();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default () => new Promise(resolve => {
2+
resolve({
3+
files: 'this-should-not-work'
4+
});
5+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const config = {}; // eslint-disable-line import/prefer-default-export
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 'should not work!';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)