Skip to content

Commit

Permalink
fix: wrong node place / children
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianCataldo committed Sep 10, 2022
1 parent e4dfc21 commit a736d5d
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const casePoliceDicts: Dict = {
...products,
...softwares,
};
const casePoliceKeys = Object.entries(casePoliceDicts).map(([key]) => key);
const casePoliceKeys = Object.entries(casePoliceDicts).map(([token]) => token);

export interface Settings {
/** List of words to ignore */
Expand All @@ -41,18 +41,15 @@ const retextCasePolice: Plugin<[Settings] | [], Root> =
const actualLowerCased = actual.toLowerCase();
const expected = casePoliceDicts[actualLowerCased];

// NOTE: Checking `WordNode` is redundant? (https://github.com/retextjs/retext/pull/78#issuecomment-1233442116)
if (nodes[0].type === 'WordNode') {
if (!ignore.includes(expected) && actual !== expected) {
const msg = file.message(
`Expected casing of \`${expected}\` instead of \`${actual}\``,
nodes[0].children[0],
`retext-case-police:${expected}`,
);
// `ruleId` and `expected` seems redundant with `origin`, should do visual tests with IDE, CLI, Monaco, etc.
msg.ruleId = 'retext-case-police';
msg.actual = actual;
msg.expected = [expected];
if (!ignore.includes(expected) && actual !== expected) {
const msg = file.message(
`Expected casing of \`${expected}\` instead of \`${actual}\``,
nodes[0],
`retext-case-police:${expected}`,
);
msg.ruleId = 'retext-case-police';
msg.actual = actual;
msg.expected = [expected];
msg.url = url;
}
});
Expand Down

0 comments on commit a736d5d

Please sign in to comment.