Skip to content

Commit 65e1478

Browse files
committed
style(oxlint/plugins): format test fixtures
1 parent 81e179c commit 65e1478

File tree

15 files changed

+92
-69
lines changed

15 files changed

+92
-69
lines changed

apps/oxlint/test/fixtures/comments/plugin.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ const testCommentsRule: Rule = {
2929
assert(topLevelFunction.type === 'FunctionDeclaration');
3030

3131
context.report({
32-
message: 'commentsExistBetween(topLevelVariable2, topLevelFunction): ' +
32+
message:
33+
'commentsExistBetween(topLevelVariable2, topLevelFunction): ' +
3334
sourceCode.commentsExistBetween(topLevelVariable2, topLevelFunction),
3435
node: topLevelVariable2,
3536
});
3637

3738
// Test `commentsExistBetween` returns `false` when start node is after end node
3839
context.report({
39-
message: 'commentsExistBetween(topLevelFunction, topLevelVariable2): ' +
40+
message:
41+
'commentsExistBetween(topLevelFunction, topLevelVariable2): ' +
4042
sourceCode.commentsExistBetween(topLevelFunction, topLevelVariable2),
4143
node: topLevelFunction,
4244
});
@@ -50,7 +52,8 @@ const testCommentsRule: Rule = {
5052
assert(init !== null);
5153

5254
context.report({
53-
message: `VariableDeclaration(${id.name}):\n` +
55+
message:
56+
`VariableDeclaration(${id.name}):\n` +
5457
`getCommentsBefore: ${formatComments(sourceCode.getCommentsBefore(node))}\n` +
5558
`getCommentsInside: ${formatComments(sourceCode.getCommentsInside(node))}\n` +
5659
`getCommentsAfter: ${formatComments(sourceCode.getCommentsAfter(node))}\n` +
@@ -60,7 +63,8 @@ const testCommentsRule: Rule = {
6063
},
6164
FunctionDeclaration(node) {
6265
context.report({
63-
message: `FunctionDeclaration(${node.id.name}):\n` +
66+
message:
67+
`FunctionDeclaration(${node.id.name}):\n` +
6468
`getCommentsBefore: ${formatComments(sourceCode.getCommentsBefore(node))}\n` +
6569
`getCommentsInside: ${formatComments(sourceCode.getCommentsInside(node))}\n` +
6670
`getCommentsAfter: ${formatComments(sourceCode.getCommentsAfter(node))}`,

apps/oxlint/test/fixtures/estree/plugin.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const plugin: Plugin = {
1616
return {
1717
Program(program) {
1818
context.report({
19-
message: 'program:\n' +
19+
message:
20+
'program:\n' +
2021
`start/end: [${program.start},${program.end}]\n` +
2122
`range: [${program.range}]\n` +
2223
`loc: [${JSON.stringify(program.loc)}]`,
@@ -48,7 +49,8 @@ const plugin: Plugin = {
4849
assert(loc2 === loc);
4950

5051
context.report({
51-
message: `ident "${ident.name}":\n` +
52+
message:
53+
`ident "${ident.name}":\n` +
5254
`start/end: [${ident.start},${ident.end}]\n` +
5355
`range: [${ident.range}]\n` +
5456
`loc: [${JSON.stringify(loc)}]`,
@@ -94,11 +96,11 @@ const plugin: Plugin = {
9496
},
9597
TSUnionType(union) {
9698
// `types` should not be `TSParenthesizedType`
97-
visits.push(`${union.type}: (types: ${union.types.map(t => t.type).join(', ')})`);
99+
visits.push(`${union.type}: (types: ${union.types.map((t) => t.type).join(', ')})`);
98100
},
99101
'TSUnionType:exit'(union) {
100102
// `types` should not be `TSParenthesizedType`
101-
visits.push(`${union.type}:exit: (types: ${union.types.map(t => t.type).join(', ')})`);
103+
visits.push(`${union.type}:exit: (types: ${union.types.map((t) => t.type).join(', ')})`);
102104
},
103105
TSNumberKeyword(keyword) {
104106
visits.push(keyword.type);

apps/oxlint/test/fixtures/fixes/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const plugin: Plugin = {
55
name: 'fixes-plugin',
66
},
77
rules: {
8-
'fixes': {
8+
fixes: {
99
meta: {
1010
fixable: 'code',
1111
},

apps/oxlint/test/fixtures/isSpaceBetween/plugin.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ const testRule: Rule = {
5959

6060
// We get this wrong. Should be `false`, but we get `true`.
6161
context.report({
62-
message:
63-
'\n' +
64-
`isSpaceBetween(beforeString, afterString): ${isSpaceBetween(beforeString, afterString)}\n` +
65-
`isSpaceBetween(afterString, beforeString): ${isSpaceBetween(afterString, beforeString)}`,
66-
node,
67-
});
62+
message:
63+
'\n' +
64+
`isSpaceBetween(beforeString, afterString): ${isSpaceBetween(beforeString, afterString)}\n` +
65+
`isSpaceBetween(afterString, beforeString): ${isSpaceBetween(afterString, beforeString)}`,
66+
node,
67+
});
6868
},
6969
};
7070
},

apps/oxlint/test/fixtures/parent/plugin.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ const plugin: Plugin = {
99
create(context) {
1010
function reportAncestry(node: any) {
1111
context.report({
12-
message: `${node.type}:\n` +
12+
message:
13+
`${node.type}:\n` +
1314
`parent: ${node.parent?.type}\n` +
14-
// @ts-ignore
15-
`ancestors: [ ${context.sourceCode.getAncestors(node).map(node => node.type).join(', ')} ]`,
15+
`ancestors: [ ${context.sourceCode
16+
.getAncestors(node)
17+
// @ts-expect-error - Shouldn't be an error. We need to fix our types.
18+
.map((node) => node.type)
19+
.join(', ')} ]`,
1620
node,
1721
});
1822
}

apps/oxlint/test/fixtures/scope_manager/plugin.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ const rule: Rule = {
2424
assert.equal(moduleScope.upper, scopeManager.globalScope);
2525

2626
context.report({
27-
message: `File has ${scopeManager.scopes.length} scopes: ${
28-
scopeManager.scopes.map((s: any) => s.block?.id?.name ?? '<' + s.constructor.name + '>').join(', ')
29-
}`,
27+
message: `File has ${scopeManager.scopes.length} scopes: ${scopeManager.scopes
28+
.map((s: any) => s.block?.id?.name ?? '<' + s.constructor.name + '>')
29+
.join(', ')}`,
3030
node: SPAN,
3131
});
3232

@@ -37,9 +37,9 @@ const rule: Rule = {
3737
if (node.declarations[0].id.type === 'ObjectPattern') {
3838
const variables = context.sourceCode.scopeManager.getDeclaredVariables(node);
3939
context.report({
40-
message: `VariableDeclaration declares ${variables.length} variables: ${
41-
variables.map(v => v.name).join(', ')
42-
}.`,
40+
message: `VariableDeclaration declares ${variables.length} variables: ${variables
41+
.map((v) => v.name)
42+
.join(', ')}.`,
4343
node: node,
4444
});
4545
}
@@ -49,9 +49,9 @@ const rule: Rule = {
4949
const topLevelFunctionScope = context.sourceCode.scopeManager.acquire(node)!;
5050
assert.equal(topLevelFunctionScope.upper, moduleScope);
5151
context.report({
52-
message: `topLevelFunction has ${topLevelFunctionScope.variables.length} local variables: ${
53-
topLevelFunctionScope?.variables.map(v => v.name).join(', ')
54-
}. Child scopes: ${topLevelFunctionScope.childScopes.length}.`,
52+
message: `topLevelFunction has ${topLevelFunctionScope.variables.length} local variables: ${topLevelFunctionScope?.variables
53+
.map((v) => v.name)
54+
.join(', ')}. Child scopes: ${topLevelFunctionScope.childScopes.length}.`,
5555
node: topLevelFunctionScope.block,
5656
});
5757
}
@@ -61,9 +61,9 @@ const rule: Rule = {
6161
const topLevelModuleScope = context.sourceCode.scopeManager.acquire(node)!;
6262
assert.equal(topLevelModuleScope.upper, moduleScope);
6363
context.report({
64-
message: `TopLevelModule has ${topLevelModuleScope.variables.length} local variables: ${
65-
topLevelModuleScope?.variables.map(v => v.name).join(', ')
66-
}. Child scopes: ${topLevelModuleScope.childScopes.length}.`,
64+
message: `TopLevelModule has ${topLevelModuleScope.variables.length} local variables: ${topLevelModuleScope?.variables
65+
.map((v) => v.name)
66+
.join(', ')}. Child scopes: ${topLevelModuleScope.childScopes.length}.`,
6767
node: topLevelModuleScope.block,
6868
});
6969
}
@@ -78,19 +78,19 @@ const rule: Rule = {
7878
assert('name' in upperBlock.id);
7979
assert.equal(upperBlock.id.name, 'TestClass');
8080
context.report({
81-
message: `TestClass static block has ${staticBlockScope.variables.length} local variables: ${
82-
staticBlockScope?.variables.map(v => v.name).join(', ')
83-
}. Child scopes: ${staticBlockScope.childScopes.length}.`,
81+
message: `TestClass static block has ${staticBlockScope.variables.length} local variables: ${staticBlockScope?.variables
82+
.map((v) => v.name)
83+
.join(', ')}. Child scopes: ${staticBlockScope.childScopes.length}.`,
8484
node: node,
8585
});
8686
},
8787
LabeledStatement(node) {
8888
const labeledStatementScope = context.sourceCode.scopeManager.acquire(node.body)!;
8989
assert.equal(labeledStatementScope.upper, moduleScope);
9090
context.report({
91-
message: `LabeledStatement's block has ${labeledStatementScope.variables.length} local variables: ${
92-
labeledStatementScope?.variables.map(v => v.name).join(', ')
93-
}. Child scopes: ${labeledStatementScope.childScopes.length}.`,
91+
message: `LabeledStatement's block has ${labeledStatementScope.variables.length} local variables: ${labeledStatementScope?.variables
92+
.map((v) => v.name)
93+
.join(', ')}. Child scopes: ${labeledStatementScope.childScopes.length}.`,
9494
node: node,
9595
});
9696
},

apps/oxlint/test/fixtures/selector/files/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ const obj = { a: [b, c], ...d };
33
function foo() {}
44
function bar() {}
55

6-
(() => {});
6+
() => {};

apps/oxlint/test/fixtures/selector/output.snap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
3 | | function foo() {}
118118
4 | | function bar() {}
119119
5 | |
120-
6 | `-> (() => {});
120+
6 | `-> () => {};
121121
`----
122122
123123
Found 0 warnings and 1 error.

apps/oxlint/test/fixtures/selector/plugin.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,18 @@ const plugin: Plugin = {
5959
}
6060

6161
visitor['Program:exit'] = (program) => {
62-
const visitLog = visits.map(({ key, node }) => {
63-
const { type } = node;
64-
let nodeDescription = type;
65-
if (type === 'Identifier') {
66-
nodeDescription += `(${node.name})`;
67-
} else if (type === 'FunctionDeclaration') {
68-
nodeDescription += `(${node.id.name})`;
69-
}
70-
return `${key}: ${nodeDescription}`;
71-
}).join('\n');
62+
const visitLog = visits
63+
.map(({ key, node }) => {
64+
const { type } = node;
65+
let nodeDescription = type;
66+
if (type === 'Identifier') {
67+
nodeDescription += `(${node.name})`;
68+
} else if (type === 'FunctionDeclaration') {
69+
nodeDescription += `(${node.id.name})`;
70+
}
71+
return `${key}: ${nodeDescription}`;
72+
})
73+
.join('\n');
7274

7375
context.report({
7476
message: `\n${visitLog}`,

apps/oxlint/test/fixtures/settings/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const rule: Rule = {
1515
const settings = context.settings;
1616

1717
// Report each setting key and value
18-
Object.keys(settings).forEach(key => {
18+
Object.keys(settings).forEach((key) => {
1919
const value = settings[key];
2020
context.report({
2121
message: `setting ${key}: ${JSON.stringify(value)}`,

0 commit comments

Comments
 (0)