Skip to content

Commit

Permalink
Add tests for postprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Dec 1, 2023
1 parent df66445 commit 9cba006
Show file tree
Hide file tree
Showing 12 changed files with 1,644 additions and 0 deletions.
410 changes: 410 additions & 0 deletions tests/fixtures/common.expected.messages.js

Large diffs are not rendered by default.

405 changes: 405 additions & 0 deletions tests/fixtures/common.messages.js

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions tests/fixtures/each-do.expected.messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const messages = [
{
ruleId: "no-empty",
severity: 2,
message: "Empty block statement.",
line: 1,
column: 21,
nodeType: "BlockStatement",
messageId: "unexpected",
endLine: 1,
endColumn: 23,
suggestions: [
{
messageId: "suggestComment",
data: { type: "block" },
fix: { range: [21, 21], text: " /* empty */ " },
desc: "Add comment inside empty block statement.",
},
],
suppressions: [{ kind: "directive", justification: "" }],
},
{
ruleId: "@stylistic/quotes",
severity: 2,
message: "Strings must use doublequote.",
line: 2,
column: 13,
nodeType: "Literal",
messageId: "wrongQuotes",
endLine: 2,
endColumn: 23,
fix: {
range: [37, 47],
text: "\"<%= j %>\"",
},
},
{
ruleId: "no-empty",
severity: 2,
message: "Empty block statement.",
line: 3,
column: 21,
nodeType: "BlockStatement",
messageId: "unexpected",
endLine: 3,
endColumn: 23,
suggestions: [
{
messageId: "suggestComment",
data: { type: "block" },
fix: { range: [134, 134], text: " /* empty */ " },
desc: "Add comment inside empty block statement.",
},
],
suppressions: [{ kind: "directive", justification: "" }],
},
{
ruleId: "@stylistic/eol-last",
severity: 2,
message: "Newline required at end of file but not found.",
line: 3,
column: 10,
nodeType: "Program",
messageId: "missing",
fix: { range: [72, 72], text: "\n" },
},
];

module.exports = messages;
69 changes: 69 additions & 0 deletions tests/fixtures/each-do.messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const messages = [
{
ruleId: "no-empty",
severity: 2,
message: "Empty block statement.",
line: 1,
column: 21,
nodeType: "BlockStatement",
messageId: "unexpected",
endLine: 1,
endColumn: 23,
suggestions: [
{
messageId: "suggestComment",
data: { type: "block" },
fix: { range: [21, 21], text: " /* empty */ " },
desc: "Add comment inside empty block statement.",
},
],
suppressions: [{ kind: "directive", justification: "" }],
},
{
ruleId: "@stylistic/quotes",
severity: 2,
message: "Strings must use doublequote.",
line: 2,
column: 13,
nodeType: "Literal",
messageId: "wrongQuotes",
endLine: 2,
endColumn: 56,
fix: {
range: [54, 97],
text: "\"/* eslint-disable */{}/* eslint-enable */\"",
},
},
{
ruleId: "no-empty",
severity: 2,
message: "Empty block statement.",
line: 3,
column: 21,
nodeType: "BlockStatement",
messageId: "unexpected",
endLine: 3,
endColumn: 23,
suggestions: [
{
messageId: "suggestComment",
data: { type: "block" },
fix: { range: [134, 134], text: " /* empty */ " },
desc: "Add comment inside empty block statement.",
},
],
suppressions: [{ kind: "directive", justification: "" }],
},
{
ruleId: "@stylistic/eol-last",
severity: 2,
message: "Newline required at end of file but not found.",
line: 3,
column: 42,
nodeType: "Program",
messageId: "missing",
fix: { range: [154, 154], text: "\n" },
},
];

module.exports = messages;
81 changes: 81 additions & 0 deletions tests/fixtures/multi-line.expected.messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
const messages = [
{
ruleId: "@stylistic/indent",
severity: 2,
message: "Expected indentation of 0 spaces but found 4.",
line: 1,
column: 1,
nodeType: "Keyword",
messageId: "wrongIndentation",
endLine: 1,
endColumn: 5,
fix: { range: [0, 4], text: "" },
},
{
ruleId: "no-unused-vars",
severity: 1,
message: "'a' is assigned a value but never used.",
line: 1,
column: 11,
nodeType: "Identifier",
messageId: "unusedVar",
endLine: 1,
endColumn: 12,
},
{
ruleId: "@stylistic/semi",
severity: 2,
message: "Missing semicolon.",
line: 1,
column: 23,
nodeType: "VariableDeclaration",
messageId: "missingSemi",
endLine: 2,
endColumn: 1,
fix: { range: [22, 22], text: ";" },
},
{
ruleId: "no-empty",
severity: 2,
message: "Empty block statement.",
line: 2,
column: 21,
nodeType: "BlockStatement",
messageId: "unexpected",
endLine: 2,
endColumn: 23,
suggestions: [
{
messageId: "suggestComment",
data: { type: "block" },
fix: { range: [44, 44], text: " /* empty */ " },
desc: "Add comment inside empty block statement.",
},
],
suppressions: [{ kind: "directive", justification: "" }],
},
{
ruleId: "@stylistic/indent",
severity: 2,
message: "Expected indentation of 0 spaces but found 1.",
line: 5,
column: 1,
nodeType: "Identifier",
messageId: "wrongIndentation",
endLine: 5,
endColumn: 2,
fix: { range: [144, 145], text: "" },
},
{
ruleId: "@stylistic/eol-last",
severity: 2,
message: "Newline required at end of file but not found.",
line: 5,
column: 28,
nodeType: "Program",
messageId: "missing",
fix: { range: [171, 171], text: "\n" },
},
];

module.exports = messages;
81 changes: 81 additions & 0 deletions tests/fixtures/multi-line.messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
const messages = [
{
ruleId: "@stylistic/indent",
severity: 2,
message: "Expected indentation of 0 spaces but found 4.",
line: 1,
column: 1,
nodeType: "Keyword",
messageId: "wrongIndentation",
endLine: 1,
endColumn: 5,
fix: { range: [0, 4], text: "" },
},
{
ruleId: "no-unused-vars",
severity: 1,
message: "'a' is assigned a value but never used.",
line: 1,
column: 11,
nodeType: "Identifier",
messageId: "unusedVar",
endLine: 1,
endColumn: 12,
},
{
ruleId: "@stylistic/semi",
severity: 2,
message: "Missing semicolon.",
line: 1,
column: 23,
nodeType: "VariableDeclaration",
messageId: "missingSemi",
endLine: 2,
endColumn: 1,
fix: { range: [22, 22], text: ";" },
},
{
ruleId: "no-empty",
severity: 2,
message: "Empty block statement.",
line: 2,
column: 21,
nodeType: "BlockStatement",
messageId: "unexpected",
endLine: 2,
endColumn: 23,
suggestions: [
{
messageId: "suggestComment",
data: { type: "block" },
fix: { range: [44, 44], text: " /* empty */ " },
desc: "Add comment inside empty block statement.",
},
],
suppressions: [{ kind: "directive", justification: "" }],
},
{
ruleId: "@stylistic/indent",
severity: 2,
message: "Expected indentation of 0 spaces but found 1.",
line: 3,
column: 1,
nodeType: "Identifier",
messageId: "wrongIndentation",
endLine: 3,
endColumn: 2,
fix: { range: [65, 66], text: "" },
},
{
ruleId: "@stylistic/eol-last",
severity: 2,
message: "Newline required at end of file but not found.",
line: 3,
column: 28,
nodeType: "Program",
messageId: "missing",
fix: { range: [92, 92], text: "\n" },
},
];

module.exports = messages;
Loading

0 comments on commit 9cba006

Please sign in to comment.