Skip to content

Commit

Permalink
feat: Simplify error message
Browse files Browse the repository at this point in the history
  • Loading branch information
sapegin committed Jun 28, 2024
1 parent 9447db1 commit f7b74a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function reporter(context, opts = {}) {

const range = [index, index + matched.length];
const fix = fixer.replaceTextRange(range, replacement);
const message = `Incorrect usage of the term: “${matched.trim()}”, use “${replacement.trim()}” instead`;
const message = `Incorrect term: “${matched.trim()}”, use “${replacement.trim()}” instead`;
report(node, new RuleError(message, { index, fix }));
}
});
Expand Down
29 changes: 10 additions & 19 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@ tester.run('textlint-rule-terminology', rule, {
output: `A GitHub\n`,
errors: [
{
message:
'Incorrect usage of the term: “Github”, use “GitHub” instead',
message: 'Incorrect term: “Github”, use “GitHub” instead',
},
],
},
Expand All @@ -291,8 +290,7 @@ tester.run('textlint-rule-terminology', rule, {
output: 'My JavaScript is good too',
errors: [
{
message:
'Incorrect usage of the term: “Javascript”, use “JavaScript” instead',
message: 'Incorrect term: “Javascript”, use “JavaScript” instead',
},
],
},
Expand All @@ -302,8 +300,7 @@ tester.run('textlint-rule-terminology', rule, {
output: 'My internet is good',
errors: [
{
message:
'Incorrect usage of the term: “Internet”, use “internet” instead',
message: 'Incorrect term: “Internet”, use “internet” instead',
},
],
},
Expand All @@ -313,8 +310,7 @@ tester.run('textlint-rule-terminology', rule, {
output: 'My bugfix is good',
errors: [
{
message:
'Incorrect usage of the term: “bug-fix”, use “bugfix” instead',
message: 'Incorrect term: “bug-fix”, use “bugfix” instead',
},
],
},
Expand All @@ -324,8 +320,7 @@ tester.run('textlint-rule-terminology', rule, {
output: 'My bugfixes are good',
errors: [
{
message:
'Incorrect usage of the term: “bug-fixes”, use “bugfixes” instead',
message: 'Incorrect term: “bug-fixes”, use “bugfixes” instead',
},
],
},
Expand All @@ -335,8 +330,7 @@ tester.run('textlint-rule-terminology', rule, {
output: 'My **JavaScript** is good',
errors: [
{
message:
'Incorrect usage of the term: “Javascript”, use “JavaScript” instead',
message: 'Incorrect term: “Javascript”, use “JavaScript” instead',
},
],
},
Expand All @@ -346,12 +340,10 @@ tester.run('textlint-rule-terminology', rule, {
output: 'Write changelogs about source maps',
errors: [
{
message:
'Incorrect usage of the term: “change logs”, use “changelogs” instead',
message: 'Incorrect term: “change logs”, use “changelogs” instead',
},
{
message:
'Incorrect usage of the term: “source-maps”, use “source maps” instead',
message: 'Incorrect term: “source-maps”, use “source maps” instead',
},
],
},
Expand All @@ -361,7 +353,7 @@ tester.run('textlint-rule-terminology', rule, {
output: 'YAML files',
errors: [
{
message: 'Incorrect usage of the term: “yaml”, use “YAML” instead',
message: 'Incorrect term: “yaml”, use “YAML” instead',
},
],
},
Expand Down Expand Up @@ -395,8 +387,7 @@ tester.run(
output: 'My wordpress is good too',
errors: [
{
message:
'Incorrect usage of the term: “WordPress”, use “wordpress” instead',
message: 'Incorrect term: “WordPress”, use “wordpress” instead',
},
],
},
Expand Down

0 comments on commit f7b74a6

Please sign in to comment.