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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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());

0 commit comments

Comments
 (0)