Skip to content

Commit 5bdf745

Browse files
GMartignysindresorhus
authored andcommitted
Add explanation in docs for fixable rules (#239)
1 parent 4846440 commit 5bdf745

11 files changed

+41
-41
lines changed

docs/rules/no-invalid-end.md

Lines changed: 1 addition & 1 deletion
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-invalid-end.md)
44

5-
AVA will fail if `t.end()` is called in a non-`cb` test function.
5+
AVA will fail if `t.end()` is called in a non-`.cb` test function.
66

77

88
## Fail

docs/rules/no-only-test.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ 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.
7+
This rule is fixable. It will remove the `.only` test modifier.
88

99

1010
## Fail

docs/rules/no-skip-test.md

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

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

5-
It's easy to make a test skipped with test.skip() and then forget about it. It's visible in the results, but still easily missed.
5+
It's easy to make a test skipped with `test.skip()` and then forget about it. It's visible in the results, but still easily missed.
66

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

99

1010
## Fail

docs/rules/no-todo-implementation.md

Lines changed: 1 addition & 1 deletion
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-todo-implementation.md)
44

5-
[`test.todo()`](https://github.com/avajs/ava/blob/master/docs/01-writing-tests.md#test-placeholders-todo) is intended for planning tests. It's not meant to be passed a function to implement the test, and if given one, AVA will throw an error. If you added an implementation, you probably meant to remove the `todo` modifier.
5+
[`test.todo()`](https://github.com/avajs/ava/blob/master/docs/01-writing-tests.md#test-placeholders-todo) is intended for planning tests. It's not meant to be passed a function to implement the test, and if given one, AVA will throw an error. If you added an implementation, you probably meant to remove the `.todo` modifier.
66

77

88
## Fail

docs/rules/use-t-well.md

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

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

5-
Prevent the use of unknown assertion methods and the access to members other than the assertion methods and `context`, as well as some known misuses of `t`.
5+
Prevent the use of unknown assertion methods and the access to members other than the assertion methods and `.context`, as well as some known misuses of `t`.
66

7-
This rule is partly fixable. It will replace misspelled `falsey` with `falsy`.
7+
This rule is partly fixable. It will replace misspelled `.falsey` with `.falsy`.
88

99

1010
## Fail
@@ -14,12 +14,12 @@ import test from 'ava';
1414

1515
test('main', t => {
1616
t(value); // `t` is not a function
17-
t.depEqual(value, [2]); // Unknown assertion method `depEqual`
18-
t.contxt.foo = 100; // Unknown member `contxt`. Use `context.contxt` instead
19-
t.foo = 1000; // Unknown member `foo`. Use `context.foo` instead
17+
t.depEqual(value, [2]); // Unknown assertion method `.depEqual`
18+
t.contxt.foo = 100; // Unknown member `.contxt`. Use `.context.contxt` instead
19+
t.foo = 1000; // Unknown member `.foo`. Use `.context.foo` instead
2020
t.deepEqual.is(value, value); // Can't chain assertion methods
2121
t.skip(); // Missing assertion method
22-
t.deepEqual.skip.skip(); // Too many chained uses of `skip`
22+
t.deepEqual.skip.skip(); // Too many chained uses of `.skip`
2323
});
2424
```
2525

rules/no-duplicate-modifiers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const create = context => {
3333
if (prev.name === current.name) {
3434
context.report({
3535
node: current,
36-
message: `Duplicate test modifier \`${current.name}\`.`
36+
message: `Duplicate test modifier \`.${current.name}\`.`
3737
});
3838
}
3939

rules/no-unknown-modifiers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const create = context => {
3333
if (unknown.length !== 0) {
3434
context.report({
3535
node: unknown[0],
36-
message: `Unknown test modifier \`${unknown[0].name}\`.`
36+
message: `Unknown test modifier \`.${unknown[0].name}\`.`
3737
});
3838
}
3939
})

rules/use-t-well.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const create = context => {
6666
// Except `t.context()`
6767
context.report({
6868
node,
69-
message: 'Unknown assertion method `context`.'
69+
message: 'Unknown assertion method `.context`.'
7070
});
7171
}
7272

@@ -79,7 +79,7 @@ const create = context => {
7979
// Except `t.title()`
8080
context.report({
8181
node,
82-
message: 'Unknown assertion method `title`.'
82+
message: 'Unknown assertion method `.title`.'
8383
});
8484
}
8585

@@ -90,17 +90,17 @@ const create = context => {
9090
if (stats.other.length > 0) {
9191
context.report({
9292
node,
93-
message: `Unknown assertion method \`${stats.other[0]}\`.`
93+
message: `Unknown assertion method \`.${stats.other[0]}\`.`
9494
});
9595
} else if (stats.skip.length > 1) {
9696
context.report({
9797
node,
98-
message: 'Too many chained uses of `skip`.'
98+
message: 'Too many chained uses of `.skip`.'
9999
});
100100
} else if (stats.falsey.length > 0) {
101101
context.report({
102102
node,
103-
message: 'Misspelled `falsy` as `falsey`.',
103+
message: 'Misspelled `.falsy` as `.falsey`.',
104104
fix: fixer => fixer.replaceText(node.property, 'falsy')
105105
});
106106
} else if (stats.method.length > 1) {
@@ -117,7 +117,7 @@ const create = context => {
117117
} else if (stats.other.length > 0) {
118118
context.report({
119119
node,
120-
message: `Unknown member \`${stats.other[0]}\`. Use \`context.${stats.other[0]}\` instead.`
120+
message: `Unknown member \`.${stats.other[0]}\`. Use \`.context.${stats.other[0]}\` instead.`
121121
});
122122
}
123123
})

test/no-duplicate-modifiers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const invalid = modifiers.map(modifier => ({
3131
errors: [
3232
{
3333
ruleId,
34-
message: `Duplicate test modifier \`${modifier}\`.`,
34+
message: `Duplicate test modifier \`.${modifier}\`.`,
3535
type: 'Identifier',
3636
line: 2,
3737
column: 7 + modifier.length
@@ -55,7 +55,7 @@ ruleTester.run('no-duplicate-modifiers', rule, {
5555
errors: [
5656
{
5757
ruleId,
58-
message: 'Duplicate test modifier `serial`.',
58+
message: 'Duplicate test modifier `.serial`.',
5959
type: 'Identifier',
6060
line: 2,
6161
column: 21

test/no-unknown-modifiers.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ruleTester.run('no-unknown-modifiers', rule, {
3535
code: `${header}test.foo(t => {});`,
3636
errors: [{
3737
ruleId,
38-
message: 'Unknown test modifier `foo`.',
38+
message: 'Unknown test modifier `.foo`.',
3939
type: 'Identifier',
4040
line: 2,
4141
column: 6
@@ -45,7 +45,7 @@ ruleTester.run('no-unknown-modifiers', rule, {
4545
code: `${header}test.onlu(t => {});`,
4646
errors: [{
4747
ruleId,
48-
message: 'Unknown test modifier `onlu`.',
48+
message: 'Unknown test modifier `.onlu`.',
4949
type: 'Identifier',
5050
line: 2,
5151
column: 6
@@ -55,7 +55,7 @@ ruleTester.run('no-unknown-modifiers', rule, {
5555
code: `${header}test.beforeeach(t => {});`,
5656
errors: [{
5757
ruleId,
58-
message: 'Unknown test modifier `beforeeach`.',
58+
message: 'Unknown test modifier `.beforeeach`.',
5959
type: 'Identifier',
6060
line: 2,
6161
column: 6
@@ -65,7 +65,7 @@ ruleTester.run('no-unknown-modifiers', rule, {
6565
code: `${header}test.c.only(t => {});`,
6666
errors: [{
6767
ruleId,
68-
message: 'Unknown test modifier `c`.',
68+
message: 'Unknown test modifier `.c`.',
6969
type: 'Identifier',
7070
line: 2,
7171
column: 6
@@ -75,7 +75,7 @@ ruleTester.run('no-unknown-modifiers', rule, {
7575
code: `${header}test.cb.onlu(t => {});`,
7676
errors: [{
7777
ruleId,
78-
message: 'Unknown test modifier `onlu`.',
78+
message: 'Unknown test modifier `.onlu`.',
7979
type: 'Identifier',
8080
line: 2,
8181
column: 9
@@ -85,7 +85,7 @@ ruleTester.run('no-unknown-modifiers', rule, {
8585
code: `${header}test.foo.bar.baz(t => {});`,
8686
errors: [{
8787
ruleId,
88-
message: 'Unknown test modifier `foo`.',
88+
message: 'Unknown test modifier `.foo`.',
8989
type: 'Identifier',
9090
line: 2,
9191
column: 6
@@ -95,7 +95,7 @@ ruleTester.run('no-unknown-modifiers', rule, {
9595
code: `${header}test.default(t => {});`,
9696
errors: [{
9797
ruleId,
98-
message: 'Unknown test modifier `default`.',
98+
message: 'Unknown test modifier `.default`.',
9999
type: 'Identifier',
100100
line: 2,
101101
column: 6
@@ -105,7 +105,7 @@ ruleTester.run('no-unknown-modifiers', rule, {
105105
code: `${header}test.test(t => {});`,
106106
errors: [{
107107
ruleId,
108-
message: 'Unknown test modifier `test`.',
108+
message: 'Unknown test modifier `.test`.',
109109
type: 'Identifier',
110110
line: 2,
111111
column: 6

0 commit comments

Comments
 (0)