Skip to content

Commit 7542453

Browse files
committed
Use CJS syntax in documentation
Out of the box, ESM syntax will only work in Node.js 13, so having that as the default example is misleading.
1 parent 4d95e28 commit 7542453

29 files changed

+66
-66
lines changed

docs/rules/assertion-arguments.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Assertion messages are optional arguments that can be given to any assertion cal
99
## Fail
1010

1111
```js
12-
import test from 'ava';
12+
const test = require('ava');
1313

1414
test(t => {
1515
t.is(value); // Not enough arguments
@@ -31,7 +31,7 @@ test(t => {
3131
## Pass
3232

3333
```js
34-
import test from 'ava';
34+
const test = require('ava');
3535

3636
test(t => {
3737
t.is(value, expected);

docs/rules/hooks-order.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This rule is fixable as long as no other code is between the hooks that need to
1818
## Fail
1919

2020
```js
21-
import test from 'ava';
21+
const test = require('ava');
2222

2323
test.after(t => {
2424
doFoo();
@@ -34,7 +34,7 @@ test('foo', t => {
3434
```
3535

3636
```js
37-
import test from 'ava';
37+
const test = require('ava');
3838

3939
test('foo', t => {
4040
t.true(true);
@@ -49,7 +49,7 @@ test.before(t => {
4949
## Pass
5050

5151
```js
52-
import test from 'ava';
52+
const test = require('ava');
5353

5454
test.before(t => {
5555
doFoo();

docs/rules/max-asserts.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Skipped assertions are counted.
1111

1212
```js
1313
/*eslint ava/max-asserts: ["error", 5]*/
14-
import test from 'ava';
14+
const test = require('ava');
1515

1616
test('getSomeObject should define the players\' names', t => {
1717
const object = lib.getSomeObject();
@@ -30,7 +30,7 @@ test('getSomeObject should define the players\' names', t => {
3030
## Pass
3131

3232
```js
33-
import test from 'ava';
33+
const test = require('ava');
3434

3535
test('getSomeObject should define the player\'s name', t => {
3636
const object = lib.getSomeObject();

docs/rules/no-async-fn-without-await.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This rule will report an error when it finds an async test which does not use th
1212
## Fail
1313

1414
```js
15-
import test from 'ava';
15+
const test = require('ava');
1616

1717
test(async t => {
1818
return foo().then(res => {
@@ -25,7 +25,7 @@ test(async t => {
2525
## Pass
2626

2727
```js
28-
import test from 'ava';
28+
const test = require('ava');
2929

3030
test(async t => {
3131
t.is(await foo(), 1);

docs/rules/no-cb-test.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Disallow the use of `test.cb()`. We instead recommend using `test()` with an asy
88
## Fail
99

1010
```js
11-
import test from 'ava';
11+
const test = require('ava');
1212

1313
test.cb('some test', t => {
1414
t.pass();
@@ -20,7 +20,7 @@ test.cb('some test', t => {
2020
## Pass
2121

2222
```js
23-
import test from 'ava';
23+
const test = require('ava');
2424

2525
test('some test', async t => {
2626
t.pass();

docs/rules/no-duplicate-modifiers.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Prevent the use of duplicate [test modifiers](https://github.com/avajs/ava/blob/
88
## Fail
99

1010
```js
11-
import test from 'ava';
11+
const test = require('ava');
1212

1313
test.only.only(t => {});
1414
test.serial.serial(t => {});
@@ -21,7 +21,7 @@ test.only.only.cb(t => {});
2121
## Pass
2222

2323
```js
24-
import test from 'ava';
24+
const test = require('ava');
2525

2626
test.only(t => {});
2727
test.serial(t => {});

docs/rules/no-identical-title.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Disallow tests with identical titles as it makes it hard to differentiate them.
88
## Fail
99

1010
```js
11-
import test from 'ava';
11+
const test = require('ava');
1212

1313
test('foo', t => {
1414
t.pass();
@@ -23,7 +23,7 @@ test('foo', t => {
2323
## Pass
2424

2525
```js
26-
import test from 'ava';
26+
const test = require('ava');
2727

2828
test(t => {
2929
t.pass();

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ This rule will verify that files which create tests are treated as test files by
1010
```js
1111
// File: test/_helper.js
1212
// Invalid because a helper.
13-
import test from 'ava';
13+
const test = require('ava');
1414

1515
test('foo', t => {
1616
t.pass();
1717
});
1818

1919
// File: lib/foo.js
2020
// Invalid because not a test file.
21-
import test from 'ava';
21+
const test = require('ava');
2222

2323
test('foo', t => {
2424
t.pass();
@@ -30,7 +30,7 @@ test('foo', t => {
3030

3131
```js
3232
// File: test/foo.js
33-
import test from 'ava';
33+
const test = require('ava');
3434

3535
test('foo', t => {
3636
t.pass();

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ This rule will verify that you don't import any test files. It will consider the
1010
```js
1111
// File: src/index.js
1212
// Invalid because *.test.js is considered as a test file.
13-
import tests from './index.test.js';
13+
const tests = require('./index.test.js');
1414
```
1515

1616
```js
1717
// File: src/index.js
1818
// Invalid because any files inside __tests__ are considered test files
19-
import tests from './__tests__/index.js';
19+
const tests = require('./__tests__/index.js');
2020

2121
test('foo', t => {
2222
t.pass();
@@ -28,13 +28,13 @@ test('foo', t => {
2828

2929
```js
3030
// File: src/index.js
31-
import sinon from 'sinon';
31+
const sinon = require('sinon');
3232

3333
```
3434

3535
```js
3636
// File: src/index.js
37-
import utils from './utils';
37+
const utils = require('./utils');
3838
```
3939

4040
## Options

docs/rules/no-inline-assertions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This rule is fixable. It will wrap the assertion in braces `{}`. It will not do
1010
## Fail
1111

1212
```js
13-
import test from 'ava';
13+
const test = require('ava');
1414

1515
test('foo', t => t.true(fn()));
1616
```
@@ -19,7 +19,7 @@ test('foo', t => t.true(fn()));
1919
## Pass
2020

2121
```js
22-
import test from 'ava';
22+
const test = require('ava');
2323

2424
test('foo', t => {
2525
t.true(fn());

docs/rules/no-invalid-end.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ AVA will fail if `t.end()` is called in a non-`.cb` test function.
88
## Fail
99

1010
```js
11-
import test from 'ava';
11+
const test = require('ava');
1212

1313
test('some test', t => {
1414
t.pass();
@@ -20,7 +20,7 @@ test('some test', t => {
2020
## Pass
2121

2222
```js
23-
import test from 'ava';
23+
const test = require('ava');
2424

2525
test('some test', t => {
2626
t.pass();

docs/rules/no-nested-tests.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ In AVA, you cannot nest tests, for example, create tests inside of other tests.
88
## Fail
99

1010
```js
11-
import test from 'ava';
11+
const test = require('ava');
1212

1313
test('foo', t => {
1414
const result = foo();
@@ -24,7 +24,7 @@ test('foo', t => {
2424
## Pass
2525

2626
```js
27-
import test from 'ava';
27+
const test = require('ava');
2828

2929
test('foo', t => {
3030
const result = foo();

docs/rules/no-only-test.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ Translations: [Français](https://github.com/avajs/ava-docs/blob/master/fr_FR/re
44

55
It's easy to run only one test with `test.only()` and then forget about it. It's visible in the results, but still easily missed. Forgetting to remove `.only`, means only this one test in the whole file will run, and if not caught, can let serious bugs slip into your codebase.
66

7-
This rule is fixable. It will remove the `.only` test modifier.
7+
This rule is fixable. It will remove the `.only` test modifier.
88

99

1010
## Fail
1111

1212
```js
13-
import test from 'ava';
13+
const test = require('ava');
1414

1515
test.only('test 1', t => {
1616
t.pass();
@@ -26,7 +26,7 @@ test('test 2', t => {
2626
## Pass
2727

2828
```js
29-
import test from 'ava';
29+
const test = require('ava');
3030

3131
test('test 1', t => {
3232
t.pass();

docs/rules/no-skip-assert.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ It's easy to make an assertion skipped with `t.skip.xyz()` and then forget about
88
## Fail
99

1010
```js
11-
import test from 'ava';
11+
const test = require('ava');
1212

1313
test('some title', t => {
1414
t.skip.is(1, 1);
@@ -19,7 +19,7 @@ test('some title', t => {
1919
## Pass
2020

2121
```js
22-
import test from 'ava';
22+
const test = require('ava');
2323

2424
test('some title', t => {
2525
t.is(1, 1);

docs/rules/no-skip-test.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This rule is fixable. It will remove the `.skip` test modifier.
1010
## Fail
1111

1212
```js
13-
import test from 'ava';
13+
const test = require('ava');
1414

1515
test('foo', t => {
1616
t.pass();
@@ -25,7 +25,7 @@ test.skip('bar', t => {
2525
## Pass
2626

2727
```js
28-
import test from 'ava';
28+
const test = require('ava');
2929

3030
test('foo', t => {
3131
t.pass();

docs/rules/no-statement-after-end.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Translations: [Français](https://github.com/avajs/ava-docs/blob/master/fr_FR/re
77
## Fail
88

99
```js
10-
import test from 'ava';
10+
const test = require('ava');
1111

1212
test.cb(t => {
1313
t.end();
@@ -24,13 +24,13 @@ test.cb(t => {
2424
## Pass
2525

2626
```js
27-
import test from 'ava';
27+
const test = require('ava');
2828

2929
test.cb(t => {
3030
t.is(1, 1);
3131
t.end();
3232
});
33-
import test from 'ava';
33+
const test = require('ava');
3434

3535
test.cb(t => {
3636
if (a) {

docs/rules/no-todo-implementation.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Translations: [Français](https://github.com/avajs/ava-docs/blob/master/fr_FR/re
88
## Fail
99

1010
```js
11-
import test from 'ava';
11+
const test = require('ava');
1212

1313
test.todo('title', t => {
1414
// ...
@@ -23,7 +23,7 @@ test.todo(t => {
2323
## Pass
2424

2525
```js
26-
import test from 'ava';
26+
const test = require('ava');
2727

2828
test.todo('title');
2929

docs/rules/no-todo-test.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Disallow the use of `test.todo()`. You might want to do this to only ship featur
88
## Fail
99

1010
```js
11-
import test from 'ava';
11+
const test = require('ava');
1212

1313
test.todo('some test');
1414
```
@@ -17,7 +17,7 @@ test.todo('some test');
1717
## Pass
1818

1919
```js
20-
import test from 'ava';
20+
const test = require('ava');
2121

2222
test('some test', t => {
2323
// Some implementation

docs/rules/no-unknown-modifiers.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Prevent the use of unknown [test modifiers](https://github.com/avajs/ava/blob/ma
88
## Fail
99

1010
```js
11-
import test from 'ava';
11+
const test = require('ava');
1212

1313
test.onlu(t => {});
1414
test.seril(t => {});
@@ -21,7 +21,7 @@ test.unknown(t => {});
2121
## Pass
2222

2323
```js
24-
import test from 'ava';
24+
const test = require('ava');
2525

2626
test.only(t => {});
2727
test.serial(t => {});

0 commit comments

Comments
 (0)