Skip to content

Commit

Permalink
feat: new rule, tag-malformed
Browse files Browse the repository at this point in the history
  • Loading branch information
revelt committed Mar 15, 2021
1 parent b98d58c commit 1cca505
Show file tree
Hide file tree
Showing 10 changed files with 207 additions and 9 deletions.
5 changes: 4 additions & 1 deletion packages/emlint/coverage/coverage-summary.json
@@ -1 +1,4 @@
{"total":{"lines":{"total":2646,"covered":2571,"skipped":0,"pct":97.17},"statements":{"total":2949,"covered":2874,"skipped":0,"pct":97.46},"functions":{"total":1028,"covered":1021,"skipped":0,"pct":99.32},"branches":{"total":2296,"covered":2168,"skipped":0,"pct":94.43}}}
{"total": {"lines":{"total":2651,"covered":1025,"skipped":0,"pct":38.66},"statements":{"total":2955,"covered":1290,"skipped":0,"pct":43.65},"functions":{"total":1031,"covered":810,"skipped":0,"pct":78.56},"branches":{"total":2298,"covered":496,"skipped":0,"pct":21.58}}
,"/Users/royston/Documents/__PROJECTS/____libs2/packages/emlint/dist/emlint.esm.js": {"lines":{"total":2640,"covered":1016,"skipped":0,"pct":38.48},"functions":{"total":1027,"covered":806,"skipped":0,"pct":78.48},"statements":{"total":2944,"covered":1281,"skipped":0,"pct":43.51},"branches":{"total":2288,"covered":489,"skipped":0,"pct":21.37}}
,"/Users/royston/Documents/__PROJECTS/____libs2/packages/emlint/t-util/util.js": {"lines":{"total":11,"covered":9,"skipped":0,"pct":81.82},"functions":{"total":4,"covered":4,"skipped":0,"pct":100},"statements":{"total":11,"covered":9,"skipped":0,"pct":81.82},"branches":{"total":10,"covered":7,"skipped":0,"pct":70}}
}
24 changes: 23 additions & 1 deletion packages/emlint/dist/emlint.cjs.js
Expand Up @@ -57,7 +57,7 @@ var op__default = /*#__PURE__*/_interopDefaultLegacy(op);

var allBadCharacterRules = ["bad-character-acknowledge", "bad-character-activate-arabic-form-shaping", "bad-character-activate-symmetric-swapping", "bad-character-application-program-command", "bad-character-backspace", "bad-character-bell", "bad-character-break-permitted-here", "bad-character-cancel", "bad-character-cancel-character", "bad-character-character-tabulation-set", "bad-character-character-tabulation-with-justification", "bad-character-control-0080", "bad-character-control-0081", "bad-character-control-0084", "bad-character-control-0099", "bad-character-control-sequence-introducer", "bad-character-data-link-escape", "bad-character-delete", "bad-character-device-control-four", "bad-character-device-control-one", "bad-character-device-control-string", "bad-character-device-control-three", "bad-character-device-control-two", "bad-character-em-quad", "bad-character-em-space", "bad-character-en-quad", "bad-character-en-space", "bad-character-end-of-medium", "bad-character-end-of-protected-area", "bad-character-end-of-selected-area", "bad-character-end-of-text", "bad-character-end-of-transmission", "bad-character-end-of-transmission-block", "bad-character-enquiry", "bad-character-escape", "bad-character-figure-space", "bad-character-first-strong-isolate", "bad-character-form-feed", "bad-character-four-per-em-space", "bad-character-function-application", "bad-character-hair-space", "bad-character-ideographic-space", "bad-character-information-separator-four", "bad-character-information-separator-one", "bad-character-information-separator-three", "bad-character-information-separator-two", "bad-character-inhibit-arabic-form-shaping", "bad-character-inhibit-symmetric-swapping", "bad-character-interlinear-annotation-anchor", "bad-character-interlinear-annotation-separator", "bad-character-interlinear-annotation-terminator", "bad-character-invisible-plus", "bad-character-invisible-separator", "bad-character-invisible-times", "bad-character-left-to-right-embedding", "bad-character-left-to-right-isolate", "bad-character-left-to-right-mark", "bad-character-left-to-right-override", "bad-character-line-separator", "bad-character-line-tabulation", "bad-character-line-tabulation-set", "bad-character-medium-mathematical-space", "bad-character-message-waiting", "bad-character-narrow-no-break-space", "bad-character-national-digit-shapes", "bad-character-negative-acknowledge", "bad-character-next-line", "bad-character-no-break-here", "bad-character-nominal-digit-shapes", "bad-character-non-breaking-space", "bad-character-null", "bad-character-ogham-space-mark", "bad-character-operating-system-command", "bad-character-paragraph-separator", "bad-character-partial-line-backward", "bad-character-partial-line-forward", "bad-character-pop-directional-formatting", "bad-character-pop-directional-isolate", "bad-character-private-message", "bad-character-private-use-1", "bad-character-private-use-2", "bad-character-punctuation-space", "bad-character-replacement-character", "bad-character-reverse-line-feed", "bad-character-right-to-left-embedding", "bad-character-right-to-left-isolate", "bad-character-right-to-left-mark", "bad-character-right-to-left-override", "bad-character-set-transmit-state", "bad-character-shift-in", "bad-character-shift-out", "bad-character-single-character-introducer", "bad-character-single-shift-three", "bad-character-single-shift-two", "bad-character-six-per-em-space", "bad-character-soft-hyphen", "bad-character-start-of-heading", "bad-character-start-of-protected-area", "bad-character-start-of-selected-area", "bad-character-start-of-string", "bad-character-start-of-text", "bad-character-string-terminator", "bad-character-substitute", "bad-character-synchronous-idle", "bad-character-tabulation", "bad-character-thin-space", "bad-character-three-per-em-space", "bad-character-word-joiner", "bad-character-zero-width-joiner", "bad-character-zero-width-no-break-space", "bad-character-zero-width-non-joiner", "bad-character-zero-width-space"];

var allTagRules = ["tag-bad-self-closing", "tag-bold", "tag-closing-backslash", "tag-is-present", "tag-missing-closing", "tag-missing-opening", "tag-name-case", "tag-rogue", "tag-space-after-opening-bracket", "tag-space-before-closing-bracket", "tag-space-between-slash-and-bracket", "tag-table", "tag-void-frontal-slash", "tag-void-slash"];
var allTagRules = ["tag-bad-self-closing", "tag-bold", "tag-closing-backslash", "tag-is-present", "tag-malformed", "tag-missing-closing", "tag-missing-opening", "tag-name-case", "tag-rogue", "tag-space-after-opening-bracket", "tag-space-before-closing-bracket", "tag-space-between-slash-and-bracket", "tag-table", "tag-void-frontal-slash", "tag-void-slash"];

var allAttribRules = ["attribute-duplicate", "attribute-enforce-img-alt", "attribute-malformed", "attribute-on-closing-tag"];

Expand Down Expand Up @@ -2817,6 +2817,25 @@ function tagTable(context) {
};
}

function tagMalformed(context) {
return {
tag: function tag(node) {
if (context.str[node.end - 1] !== ">") {
var startPos = stringLeftRight.left(context.str, node.end) + 1;
context.report({
ruleId: "tag-malformed",
message: "Add a closing bracket.",
idxFrom: node.start,
idxTo: node.end,
fix: {
ranges: [[startPos, startPos, ">"]]
}
});
}
}
};
}

var BACKSLASH$1 = "\\";
function tagClosingBackslash(context) {
return {
Expand Down Expand Up @@ -9439,6 +9458,9 @@ defineLazyProp__default['default'](builtInRules, "tag-space-between-slash-and-br
defineLazyProp__default['default'](builtInRules, "tag-table", function () {
return tagTable;
});
defineLazyProp__default['default'](builtInRules, "tag-malformed", function () {
return tagMalformed;
});
defineLazyProp__default['default'](builtInRules, "tag-closing-backslash", function () {
return tagClosingBackslash;
});
Expand Down
29 changes: 28 additions & 1 deletion packages/emlint/dist/emlint.dev.umd.js
Expand Up @@ -14867,7 +14867,7 @@ var defineLazyProp = function defineLazyProp(object, propertyName, fn) {

var allBadCharacterRules = ["bad-character-acknowledge", "bad-character-activate-arabic-form-shaping", "bad-character-activate-symmetric-swapping", "bad-character-application-program-command", "bad-character-backspace", "bad-character-bell", "bad-character-break-permitted-here", "bad-character-cancel", "bad-character-cancel-character", "bad-character-character-tabulation-set", "bad-character-character-tabulation-with-justification", "bad-character-control-0080", "bad-character-control-0081", "bad-character-control-0084", "bad-character-control-0099", "bad-character-control-sequence-introducer", "bad-character-data-link-escape", "bad-character-delete", "bad-character-device-control-four", "bad-character-device-control-one", "bad-character-device-control-string", "bad-character-device-control-three", "bad-character-device-control-two", "bad-character-em-quad", "bad-character-em-space", "bad-character-en-quad", "bad-character-en-space", "bad-character-end-of-medium", "bad-character-end-of-protected-area", "bad-character-end-of-selected-area", "bad-character-end-of-text", "bad-character-end-of-transmission", "bad-character-end-of-transmission-block", "bad-character-enquiry", "bad-character-escape", "bad-character-figure-space", "bad-character-first-strong-isolate", "bad-character-form-feed", "bad-character-four-per-em-space", "bad-character-function-application", "bad-character-hair-space", "bad-character-ideographic-space", "bad-character-information-separator-four", "bad-character-information-separator-one", "bad-character-information-separator-three", "bad-character-information-separator-two", "bad-character-inhibit-arabic-form-shaping", "bad-character-inhibit-symmetric-swapping", "bad-character-interlinear-annotation-anchor", "bad-character-interlinear-annotation-separator", "bad-character-interlinear-annotation-terminator", "bad-character-invisible-plus", "bad-character-invisible-separator", "bad-character-invisible-times", "bad-character-left-to-right-embedding", "bad-character-left-to-right-isolate", "bad-character-left-to-right-mark", "bad-character-left-to-right-override", "bad-character-line-separator", "bad-character-line-tabulation", "bad-character-line-tabulation-set", "bad-character-medium-mathematical-space", "bad-character-message-waiting", "bad-character-narrow-no-break-space", "bad-character-national-digit-shapes", "bad-character-negative-acknowledge", "bad-character-next-line", "bad-character-no-break-here", "bad-character-nominal-digit-shapes", "bad-character-non-breaking-space", "bad-character-null", "bad-character-ogham-space-mark", "bad-character-operating-system-command", "bad-character-paragraph-separator", "bad-character-partial-line-backward", "bad-character-partial-line-forward", "bad-character-pop-directional-formatting", "bad-character-pop-directional-isolate", "bad-character-private-message", "bad-character-private-use-1", "bad-character-private-use-2", "bad-character-punctuation-space", "bad-character-replacement-character", "bad-character-reverse-line-feed", "bad-character-right-to-left-embedding", "bad-character-right-to-left-isolate", "bad-character-right-to-left-mark", "bad-character-right-to-left-override", "bad-character-set-transmit-state", "bad-character-shift-in", "bad-character-shift-out", "bad-character-single-character-introducer", "bad-character-single-shift-three", "bad-character-single-shift-two", "bad-character-six-per-em-space", "bad-character-soft-hyphen", "bad-character-start-of-heading", "bad-character-start-of-protected-area", "bad-character-start-of-selected-area", "bad-character-start-of-string", "bad-character-start-of-text", "bad-character-string-terminator", "bad-character-substitute", "bad-character-synchronous-idle", "bad-character-tabulation", "bad-character-thin-space", "bad-character-three-per-em-space", "bad-character-word-joiner", "bad-character-zero-width-joiner", "bad-character-zero-width-no-break-space", "bad-character-zero-width-non-joiner", "bad-character-zero-width-space"];

var allTagRules = ["tag-bad-self-closing", "tag-bold", "tag-closing-backslash", "tag-is-present", "tag-missing-closing", "tag-missing-opening", "tag-name-case", "tag-rogue", "tag-space-after-opening-bracket", "tag-space-before-closing-bracket", "tag-space-between-slash-and-bracket", "tag-table", "tag-void-frontal-slash", "tag-void-slash"];
var allTagRules = ["tag-bad-self-closing", "tag-bold", "tag-closing-backslash", "tag-is-present", "tag-malformed", "tag-missing-closing", "tag-missing-opening", "tag-name-case", "tag-rogue", "tag-space-after-opening-bracket", "tag-space-before-closing-bracket", "tag-space-between-slash-and-bracket", "tag-table", "tag-void-frontal-slash", "tag-void-slash"];

var allAttribRules = ["attribute-duplicate", "attribute-enforce-img-alt", "attribute-malformed", "attribute-on-closing-tag"];

Expand Down Expand Up @@ -18817,6 +18817,30 @@ function tagTable(context) {
};
}

// rule: tag-malformed
// checks brackets etc
// -----------------------------------------------------------------------------

function tagMalformed(context) {
return {
tag: function tag(node) { // check closing bracket

if (context.str[node.end - 1] !== ">") {
var startPos = left(context.str, node.end) + 1;
context.report({
ruleId: "tag-malformed",
message: "Add a closing bracket.",
idxFrom: node.start,
idxTo: node.end,
fix: {
ranges: [[startPos, startPos, ">"]]
}
});
}
}
};
}

// rule: tag-closing-backslash
var BACKSLASH$2 = "\\";

Expand Down Expand Up @@ -42118,6 +42142,9 @@ defineLazyProp(builtInRules, "tag-space-between-slash-and-bracket", function ()
defineLazyProp(builtInRules, "tag-table", function () {
return tagTable;
});
defineLazyProp(builtInRules, "tag-malformed", function () {
return tagMalformed;
});
defineLazyProp(builtInRules, "tag-closing-backslash", function () {
return tagClosingBackslash;
});
Expand Down
22 changes: 21 additions & 1 deletion packages/emlint/dist/emlint.esm.js
Expand Up @@ -35,7 +35,7 @@ import op from 'object-path';

var allBadCharacterRules = ["bad-character-acknowledge", "bad-character-activate-arabic-form-shaping", "bad-character-activate-symmetric-swapping", "bad-character-application-program-command", "bad-character-backspace", "bad-character-bell", "bad-character-break-permitted-here", "bad-character-cancel", "bad-character-cancel-character", "bad-character-character-tabulation-set", "bad-character-character-tabulation-with-justification", "bad-character-control-0080", "bad-character-control-0081", "bad-character-control-0084", "bad-character-control-0099", "bad-character-control-sequence-introducer", "bad-character-data-link-escape", "bad-character-delete", "bad-character-device-control-four", "bad-character-device-control-one", "bad-character-device-control-string", "bad-character-device-control-three", "bad-character-device-control-two", "bad-character-em-quad", "bad-character-em-space", "bad-character-en-quad", "bad-character-en-space", "bad-character-end-of-medium", "bad-character-end-of-protected-area", "bad-character-end-of-selected-area", "bad-character-end-of-text", "bad-character-end-of-transmission", "bad-character-end-of-transmission-block", "bad-character-enquiry", "bad-character-escape", "bad-character-figure-space", "bad-character-first-strong-isolate", "bad-character-form-feed", "bad-character-four-per-em-space", "bad-character-function-application", "bad-character-hair-space", "bad-character-ideographic-space", "bad-character-information-separator-four", "bad-character-information-separator-one", "bad-character-information-separator-three", "bad-character-information-separator-two", "bad-character-inhibit-arabic-form-shaping", "bad-character-inhibit-symmetric-swapping", "bad-character-interlinear-annotation-anchor", "bad-character-interlinear-annotation-separator", "bad-character-interlinear-annotation-terminator", "bad-character-invisible-plus", "bad-character-invisible-separator", "bad-character-invisible-times", "bad-character-left-to-right-embedding", "bad-character-left-to-right-isolate", "bad-character-left-to-right-mark", "bad-character-left-to-right-override", "bad-character-line-separator", "bad-character-line-tabulation", "bad-character-line-tabulation-set", "bad-character-medium-mathematical-space", "bad-character-message-waiting", "bad-character-narrow-no-break-space", "bad-character-national-digit-shapes", "bad-character-negative-acknowledge", "bad-character-next-line", "bad-character-no-break-here", "bad-character-nominal-digit-shapes", "bad-character-non-breaking-space", "bad-character-null", "bad-character-ogham-space-mark", "bad-character-operating-system-command", "bad-character-paragraph-separator", "bad-character-partial-line-backward", "bad-character-partial-line-forward", "bad-character-pop-directional-formatting", "bad-character-pop-directional-isolate", "bad-character-private-message", "bad-character-private-use-1", "bad-character-private-use-2", "bad-character-punctuation-space", "bad-character-replacement-character", "bad-character-reverse-line-feed", "bad-character-right-to-left-embedding", "bad-character-right-to-left-isolate", "bad-character-right-to-left-mark", "bad-character-right-to-left-override", "bad-character-set-transmit-state", "bad-character-shift-in", "bad-character-shift-out", "bad-character-single-character-introducer", "bad-character-single-shift-three", "bad-character-single-shift-two", "bad-character-six-per-em-space", "bad-character-soft-hyphen", "bad-character-start-of-heading", "bad-character-start-of-protected-area", "bad-character-start-of-selected-area", "bad-character-start-of-string", "bad-character-start-of-text", "bad-character-string-terminator", "bad-character-substitute", "bad-character-synchronous-idle", "bad-character-tabulation", "bad-character-thin-space", "bad-character-three-per-em-space", "bad-character-word-joiner", "bad-character-zero-width-joiner", "bad-character-zero-width-no-break-space", "bad-character-zero-width-non-joiner", "bad-character-zero-width-space"];

var allTagRules = ["tag-bad-self-closing", "tag-bold", "tag-closing-backslash", "tag-is-present", "tag-missing-closing", "tag-missing-opening", "tag-name-case", "tag-rogue", "tag-space-after-opening-bracket", "tag-space-before-closing-bracket", "tag-space-between-slash-and-bracket", "tag-table", "tag-void-frontal-slash", "tag-void-slash"];
var allTagRules = ["tag-bad-self-closing", "tag-bold", "tag-closing-backslash", "tag-is-present", "tag-malformed", "tag-missing-closing", "tag-missing-opening", "tag-name-case", "tag-rogue", "tag-space-after-opening-bracket", "tag-space-before-closing-bracket", "tag-space-between-slash-and-bracket", "tag-table", "tag-void-frontal-slash", "tag-void-slash"];

var allAttribRules = ["attribute-duplicate", "attribute-enforce-img-alt", "attribute-malformed", "attribute-on-closing-tag"];

Expand Down Expand Up @@ -2892,6 +2892,25 @@ function tagTable(context) {
};
}

function tagMalformed(context) {
return {
tag(node) {
if (context.str[node.end - 1] !== ">") {
const startPos = left(context.str, node.end) + 1;
context.report({
ruleId: "tag-malformed",
message: "Add a closing bracket.",
idxFrom: node.start,
idxTo: node.end,
fix: {
ranges: [[startPos, startPos, ">"]]
}
});
}
}
};
}

const BACKSLASH$1 = "\u005C";
function tagClosingBackslash(context) {
return {
Expand Down Expand Up @@ -9251,6 +9270,7 @@ defineLazyProp(builtInRules, "tag-space-after-opening-bracket", () => tagSpaceAf
defineLazyProp(builtInRules, "tag-space-before-closing-bracket", () => tagSpaceBeforeClosingBracket);
defineLazyProp(builtInRules, "tag-space-between-slash-and-bracket", () => tagSpaceBetweenSlashAndBracket);
defineLazyProp(builtInRules, "tag-table", () => tagTable);
defineLazyProp(builtInRules, "tag-malformed", () => tagMalformed);
defineLazyProp(builtInRules, "tag-closing-backslash", () => tagClosingBackslash);
defineLazyProp(builtInRules, "tag-void-slash", () => tagVoidSlash);
defineLazyProp(builtInRules, "tag-name-case", () => tagNameCase);
Expand Down
2 changes: 1 addition & 1 deletion packages/emlint/dist/emlint.mjs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/emlint/dist/emlint.umd.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion packages/emlint/src/rules.ts
Expand Up @@ -261,6 +261,8 @@ import tagSpaceBetweenSlashAndBracket from "./rules/tag/tag-space-between-slash-

import tagTable from "./rules/tag/tag-table";

import tagMalformed from "./rules/tag/tag-malformed";

import tagClosingBackslash from "./rules/tag/tag-closing-backslash";

import tagVoidSlash from "./rules/tag/tag-void-slash";
Expand Down Expand Up @@ -1175,6 +1177,7 @@ defineLazyProp(
() => tagSpaceBetweenSlashAndBracket
);
defineLazyProp(builtInRules, "tag-table", () => tagTable);
defineLazyProp(builtInRules, "tag-malformed", () => tagMalformed);
defineLazyProp(
builtInRules,
"tag-closing-backslash",
Expand Down Expand Up @@ -1980,7 +1983,7 @@ function normaliseRequestedRules(opts: RulesObj): RulesObj {
}

console.log(
`1983 normaliseRequestedRules() FINAL ${`\u001b[${33}m${`res`}\u001b[${39}m`} = ${JSON.stringify(
`1986 normaliseRequestedRules() FINAL ${`\u001b[${33}m${`res`}\u001b[${39}m`} = ${JSON.stringify(
res,
null,
4
Expand Down

0 comments on commit 1cca505

Please sign in to comment.