Skip to content

Commit c4fdffe

Browse files
authored
chore: add prettier (#234)
1 parent 6d56188 commit c4fdffe

File tree

72 files changed

+2495
-1216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2495
-1216
lines changed

.eslintrc.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
module.exports = {
44
root: true,
5+
parserOptions: {
6+
ecmaVersion: 2021,
7+
sourceType: 'script',
8+
},
59
extends: [
610
'not-an-aardvark/node',
7-
'plugin:unicorn/recommended',
811
'plugin:node/recommended',
12+
'plugin:prettier/recommended',
13+
'plugin:unicorn/recommended',
914
],
1015
rules: {
1116
'comma-dangle': [

.prettierrc.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
module.exports = {
4+
singleQuote: true,
5+
};

build/generate-readme-table.js

+28-16
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,47 @@ const END_TABLE_MARKER = '\n<!-- __END AUTOGENERATED TABLE__ -->';
1010

1111
const expectedTableLines = Object.keys(rules)
1212
.sort()
13-
.reduce((lines, ruleId) => {
14-
const rule = rules[ruleId];
15-
16-
lines.push([
17-
`[${ruleId}](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/${ruleId}.md)`,
18-
rule.meta.docs.recommended ? '✔️' : '',
19-
rule.meta.fixable ? '🛠' : '',
20-
rule.meta.hasSuggestions ? '💡' : '',
21-
rule.meta.docs.description,
22-
].join(' | '));
23-
24-
return lines;
25-
}, ['Name | ✔️ | 🛠 | 💡 | Description', '----- | ----- | ----- | ----- | -----'])
13+
.reduce(
14+
(lines, ruleId) => {
15+
const rule = rules[ruleId];
16+
17+
lines.push(
18+
[
19+
`[${ruleId}](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/${ruleId}.md)`,
20+
rule.meta.docs.recommended ? '✔️' : '',
21+
rule.meta.fixable ? '🛠' : '',
22+
rule.meta.hasSuggestions ? '💡' : '',
23+
rule.meta.docs.description,
24+
].join(' | ')
25+
);
26+
27+
return lines;
28+
},
29+
[
30+
'Name | ✔️ | 🛠 | 💡 | Description',
31+
'----- | ----- | ----- | ----- | -----',
32+
]
33+
)
2634
.join('\n');
2735

2836
const readmeContents = fs.readFileSync(README_LOCATION, 'utf8');
2937

3038
if (!readmeContents.includes(BEGIN_TABLE_MARKER)) {
31-
throw new Error(`Could not find '${BEGIN_TABLE_MARKER}' marker in README.md.`);
39+
throw new Error(
40+
`Could not find '${BEGIN_TABLE_MARKER}' marker in README.md.`
41+
);
3242
}
3343

3444
if (!readmeContents.includes(END_TABLE_MARKER)) {
3545
throw new Error(`Could not find '${END_TABLE_MARKER}' marker in README.md.`);
3646
}
3747

38-
const linesStartIndex = readmeContents.indexOf(BEGIN_TABLE_MARKER) + BEGIN_TABLE_MARKER.length;
48+
const linesStartIndex =
49+
readmeContents.indexOf(BEGIN_TABLE_MARKER) + BEGIN_TABLE_MARKER.length;
3950
const linesEndIndex = readmeContents.indexOf(END_TABLE_MARKER);
4051

41-
const updatedReadmeContents = readmeContents.slice(0, linesStartIndex) +
52+
const updatedReadmeContents =
53+
readmeContents.slice(0, linesStartIndex) +
4254
expectedTableLines +
4355
readmeContents.slice(linesEndIndex);
4456

docs/rules/fixer-return.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Examples of **incorrect** code for this rule:
1414
/* eslint eslint-plugin/fixer-return: error */
1515

1616
module.exports = {
17-
create (context) {
17+
create(context) {
1818
context.report({
19-
fix (fixer) {
19+
fix(fixer) {
2020
fixer.insertTextAfter(node, 'foo');
2121
},
2222
});
@@ -30,9 +30,9 @@ Examples of **correct** code for this rule:
3030
/* eslint eslint-plugin/fixer-return: error */
3131

3232
module.exports = {
33-
create (context) {
33+
create(context) {
3434
context.report({
35-
fix (fixer) {
35+
fix(fixer) {
3636
return fixer.insertTextAfter(node, 'foo');
3737
},
3838
});
@@ -44,9 +44,9 @@ module.exports = {
4444
/* eslint eslint-plugin/fixer-return: error */
4545

4646
module.exports = {
47-
create (context) {
47+
create(context) {
4848
context.report({
49-
fix (fixer) {
49+
fix(fixer) {
5050
if (foo) {
5151
return; // no autofix in this situation
5252
}

docs/rules/meta-property-ordering.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ This rule has an array option:
1515
Examples of **incorrect** code for this rule:
1616

1717
```js
18-
1918
/* eslint eslint-plugin/meta-property-ordering: ["error",
2019
["type", "docs", "fixable", "schema", "messages"]
2120
] */
@@ -27,7 +26,7 @@ module.exports = {
2726
type: 'problem',
2827
fixable: 'code',
2928
},
30-
create () {},
29+
create() {},
3130
};
3231

3332
// invalid; extra properties must be placed afterwards.
@@ -38,7 +37,7 @@ module.exports = {
3837
docs: '',
3938
fixable: 'code',
4039
},
41-
create () {},
40+
create() {},
4241
};
4342
```
4443

@@ -57,7 +56,7 @@ module.exports = {
5756
messages: ['zoo'],
5857
fooooooooo: 'foo',
5958
},
60-
create () {},
59+
create() {},
6160
};
6261
```
6362

docs/rules/no-deprecated-context-methods.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ Examples of **incorrect** code for this rule:
3737

3838
```js
3939
module.exports = {
40-
create (context) {
40+
create(context) {
4141
return {
42-
Program (ast) {
42+
Program(ast) {
4343
const firstToken = context.getFirstToken(ast);
4444
},
4545
};
@@ -51,11 +51,11 @@ Examples of **correct** code for this rule:
5151

5252
```js
5353
module.exports = {
54-
create (context) {
54+
create(context) {
5555
const sourceCode = context.getSourceCode();
5656

5757
return {
58-
Program (ast) {
58+
Program(ast) {
5959
const firstToken = sourceCode.getFirstToken(ast);
6060
},
6161
};

docs/rules/no-deprecated-report-api.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,17 @@ Examples of **incorrect** code for this rule:
1919

2020
```js
2121
module.exports = {
22-
create (context) {
22+
create(context) {
2323
context.report(node, 'This node is bad.');
2424
},
2525
};
26-
2726
```
2827

2928
Examples of **correct** code for this rule:
3029

3130
```js
3231
module.exports = {
33-
create (context) {
32+
create(context) {
3433
context.report({ node, message: 'This node is bad.' });
3534

3635
context.report({ node, loc, message: 'This node is bad.' });

docs/rules/no-identical-tests.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ Examples of **incorrect** code for this rule:
1414
/* eslint eslint-plugin/no-identical-tests: error */
1515

1616
new RuleTester().run('foo', bar, {
17-
valid: [
18-
{ code: 'foo' },
19-
{ code: 'foo' },
20-
],
17+
valid: [{ code: 'foo' }, { code: 'foo' }],
2118
invalid: [],
2219
});
2320
```
@@ -28,10 +25,7 @@ Examples of **correct** code for this rule:
2825
/* eslint eslint-plugin/no-identical-tests: error */
2926

3027
new RuleTester().run('foo', bar, {
31-
valid: [
32-
{ code: 'foo' },
33-
{ code: 'bar' },
34-
],
28+
valid: [{ code: 'foo' }, { code: 'bar' }],
3529
invalid: [],
3630
});
3731
```

docs/rules/no-missing-placeholders.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Examples of **incorrect** code for this rule:
2626
/* eslint eslint-plugin/no-missing-placeholders: error*/
2727

2828
module.exports = {
29-
create (context) {
29+
create(context) {
3030
context.report({
3131
node,
3232
message: '{{something}} is wrong.',
@@ -49,7 +49,7 @@ Examples of **correct** code for this rule:
4949
/* eslint eslint-plugin/no-missing-placeholders: error*/
5050

5151
module.exports = {
52-
create (context) {
52+
create(context) {
5353
context.report({
5454
node,
5555
message: 'something is wrong.',

docs/rules/no-only-tests.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ ruleTester.run('my-rule', myRule, {
3030
{
3131
code: 'const invalid = 42;',
3232
only: true,
33-
errors: [/* ... */],
33+
errors: [
34+
/* ... */
35+
],
3436
},
3537
],
3638
});
@@ -45,14 +47,13 @@ const { RuleTester } = require('eslint');
4547
const ruleTester = new RuleTester();
4648

4749
ruleTester.run('my-rule', myRule, {
48-
valid: [
49-
'const valid = 42;',
50-
{ code: 'const valid = 42;' },
51-
],
50+
valid: ['const valid = 42;', { code: 'const valid = 42;' }],
5251
invalid: [
5352
{
5453
code: 'const invalid = 42;',
55-
errors: [/* ... */],
54+
errors: [
55+
/* ... */
56+
],
5657
},
5758
],
5859
});

docs/rules/no-unused-placeholders.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Examples of **incorrect** code for this rule:
1414
/* eslint eslint-plugin/no-unused-placeholders: error*/
1515

1616
module.exports = {
17-
create (context) {
17+
create(context) {
1818
context.report({
1919
node,
2020
message: 'something is wrong.',
@@ -32,7 +32,7 @@ Examples of **correct** code for this rule:
3232
/* eslint eslint-plugin/no-unused-placeholders: error*/
3333

3434
module.exports = {
35-
create (context) {
35+
create(context) {
3636
context.report({
3737
node,
3838
message: 'something is wrong.',

docs/rules/no-useless-token-range.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Examples of **incorrect** code for this rule:
1616
/* eslint eslint-plugin/no-useless-token-range: error */
1717

1818
module.exports = {
19-
create (context) {
19+
create(context) {
2020
const sourceCode = context.getSourceCode();
2121

2222
const rangeStart = sourceCode.getFirstToken(node).range[0];
@@ -31,7 +31,7 @@ Examples of **correct** code for this rule:
3131
/* eslint eslint-plugin/no-useless-token-range: error */
3232

3333
module.exports = {
34-
create (context) {
34+
create(context) {
3535
const sourceCode = context.getSourceCode();
3636

3737
const rangeStart = node.range[0];

docs/rules/prefer-message-ids.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Examples of **incorrect** code for this rule:
1515
/* eslint eslint-plugin/prefer-message-ids: error */
1616

1717
module.exports = {
18-
create (context) {
18+
create(context) {
1919
return {
20-
CallExpression (node) {
20+
CallExpression(node) {
2121
context.report({
2222
node,
2323
message: 'Some error message.',
@@ -39,9 +39,9 @@ module.exports = {
3939
someMessageId: 'Some error message',
4040
},
4141
},
42-
create (context) {
42+
create(context) {
4343
return {
44-
CallExpression (node) {
44+
CallExpression(node) {
4545
context.report({
4646
node,
4747
messageId: 'someMessageId',

0 commit comments

Comments
 (0)