diff --git a/__tests__/examples/tag-pair/missing-closing-tag/document.html b/__tests__/examples/tag-pair/missing-closing-tag/document.html new file mode 100644 index 0000000..f6a31d8 --- /dev/null +++ b/__tests__/examples/tag-pair/missing-closing-tag/document.html @@ -0,0 +1,3 @@ +
+
1
+
2
\ No newline at end of file diff --git a/__tests__/examples/tag-pair/missing-closing-tag/errors.js b/__tests__/examples/tag-pair/missing-closing-tag/errors.js new file mode 100644 index 0000000..6ab2e9a --- /dev/null +++ b/__tests__/examples/tag-pair/missing-closing-tag/errors.js @@ -0,0 +1,15 @@ +module.exports = [ + { + type: 'error', + message: 'Tag must be paired, missing: [
], start tag match failed [
] on line 1.', + raw: '
', + evidence: '
', + line: 1, + col: 1, + rule: { + id: 'tag-pair', + description: 'Tag must be paired.', + link: 'https://thecapsule.email/docs/codes/tag-pair' + } + } +] \ No newline at end of file diff --git a/__tests__/examples/tag-pair/missing-nested-closing-tag/document.html b/__tests__/examples/tag-pair/missing-nested-closing-tag/document.html new file mode 100644 index 0000000..8de83b2 --- /dev/null +++ b/__tests__/examples/tag-pair/missing-nested-closing-tag/document.html @@ -0,0 +1,4 @@ +
+
test
+ 1 +
\ No newline at end of file diff --git a/__tests__/examples/tag-pair/missing-nested-closing-tag/errors.js b/__tests__/examples/tag-pair/missing-nested-closing-tag/errors.js new file mode 100644 index 0000000..ddc7926 --- /dev/null +++ b/__tests__/examples/tag-pair/missing-nested-closing-tag/errors.js @@ -0,0 +1,15 @@ +module.exports = [ + { + type: 'error', + message: 'Tag must be paired, missing: [ ], start tag match failed [ ] on line 3.', + raw: '', + evidence: ' 1', + line: 3, + col: 5, + rule: { + id: 'tag-pair', + description: 'Tag must be paired.', + link: 'https://thecapsule.email/docs/codes/tag-pair' + } + } +] \ No newline at end of file diff --git a/__tests__/examples/tag-pair/missing-opening-tag/document.html b/__tests__/examples/tag-pair/missing-opening-tag/document.html new file mode 100644 index 0000000..6587261 --- /dev/null +++ b/__tests__/examples/tag-pair/missing-opening-tag/document.html @@ -0,0 +1,4 @@ +
+
123
+
+
\ No newline at end of file diff --git a/__tests__/examples/tag-pair/missing-opening-tag/errors.js b/__tests__/examples/tag-pair/missing-opening-tag/errors.js new file mode 100644 index 0000000..70e77ac --- /dev/null +++ b/__tests__/examples/tag-pair/missing-opening-tag/errors.js @@ -0,0 +1,15 @@ +module.exports = [ + { + type: 'error', + message: 'Tag must be paired, no start tag: [
]', + raw: '
', + evidence: '', + line: 4, + col: 1, + rule: { + id: 'tag-pair', + description: 'Tag must be paired.', + link: 'https://thecapsule.email/docs/codes/tag-pair' + } + } +] \ No newline at end of file diff --git a/__tests__/rules.spec.ts b/__tests__/rules.spec.ts index 8e6d77a..0c848a2 100644 --- a/__tests__/rules.spec.ts +++ b/__tests__/rules.spec.ts @@ -45,9 +45,7 @@ describe('Rule: "head-no-duplicates"', () => { it('Throws errors for duplicate tags.', () => { rule('head-no-duplicates'); }); -}); - -describe('Rule: "html-no-duplicates"', () => { + it('Throws errors for duplicate tags.', () => { rule('html-no-duplicates'); }); @@ -105,4 +103,18 @@ describe('Rule: "freemarker-tags"', () => { it('Throws errors for invalid freemarker tags.', () => { rule('freemarker-tags'); }); +}); + +describe('Rule: "tag-pair"', () => { + it('Throws errors when missing closing tag.', () => { + rule('tag-pair/missing-closing-tag'); + }); + + it('Throws errors when missing nested closing tag.', () => { + rule('tag-pair/missing-nested-closing-tag'); + }); + + it('Throws errors when missing closing tag.', () => { + rule('tag-pair/missing-opening-tag'); + }); }); \ No newline at end of file diff --git a/demo/App.vue b/demo/App.vue index c7fd9a7..f80ea3f 100644 --- a/demo/App.vue +++ b/demo/App.vue @@ -3,9 +3,10 @@ import { TextareaField } from '@vue-interface/textarea-field'; import { ref, watchEffect } from 'vue'; import { lint } from '../src/index'; -const document = ref(` -

test

-`); +const document = ref(`
+
test
+ 1 +
`); const errors = ref(); @@ -16,10 +17,10 @@ watchEffect(() => {