From dfff99b94aa3edd44f2fce08e9388e0c826d716f Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Sat, 7 Nov 2020 09:53:28 +0100 Subject: [PATCH] fix(config:vue): allow void elements in "vue/html-self-closing" (#24) See https://github.com/prettier/eslint-config-prettier/issues/85 --- __tests__/fixtures/component.vue | 1 + __tests__/functional.test.ts | 20 ++++---------------- src/config-generator.test.ts | 2 +- src/config-generator.ts | 2 +- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/__tests__/fixtures/component.vue b/__tests__/fixtures/component.vue index bc12a32..0199f3d 100644 --- a/__tests__/fixtures/component.vue +++ b/__tests__/fixtures/component.vue @@ -8,6 +8,7 @@ + diff --git a/__tests__/functional.test.ts b/__tests__/functional.test.ts index c9c309b..fac53c3 100644 --- a/__tests__/functional.test.ts +++ b/__tests__/functional.test.ts @@ -87,33 +87,27 @@ describe('Functional', function () { "message": "Component name \\"transition\\" is not PascalCase.", "ruleId": "vue/component-name-in-template-casing", }, - Object { - "column": 9, - "line": 7, - "message": "Disallow self-closing on HTML void elements ().", - "ruleId": "vue/html-self-closing", - }, Object { "column": 29, - "line": 14, + "line": 15, "message": "Delete \`·\`", "ruleId": "prettier/prettier", }, Object { "column": 5, - "line": 19, + "line": 20, "message": "Component name \\"v-component\\" is not PascalCase.", "ruleId": "vue/component-name-in-template-casing", }, Object { "column": 5, - "line": 31, + "line": 32, "message": "Unexpected console statement.", "ruleId": "no-console", }, Object { "column": 17, - "line": 31, + "line": 32, "message": "Replace \`\\"Hello·world!\\"\` with \`'Hello·world!'\`", "ruleId": "prettier/prettier", }, @@ -147,12 +141,6 @@ describe('Functional', function () { "message": "Replace \`⏎········my·image:·⏎······\` with \`my·image:·\`", "ruleId": "prettier/prettier", }, - Object { - "column": 19, - "line": 6, - "message": "Disallow self-closing on HTML void elements ().", - "ruleId": "vue/html-self-closing", - }, Object { "column": 28, "line": 13, diff --git a/src/config-generator.test.ts b/src/config-generator.test.ts index aa0ab98..a661593 100644 --- a/src/config-generator.test.ts +++ b/src/config-generator.test.ts @@ -61,7 +61,7 @@ describe('Configuration generator', function () { registeredComponentsOnly: false, }, ], - 'vue/html-self-closing': ['error'], + 'vue/html-self-closing': ['error', { html: { void: 'always' } }], 'vue/no-duplicate-attr-inheritance': ['error'], 'vue/no-empty-component-block': ['error'], 'vue/no-template-target-blank': ['error'], diff --git a/src/config-generator.ts b/src/config-generator.ts index 99f5325..4ed2cea 100644 --- a/src/config-generator.ts +++ b/src/config-generator.ts @@ -96,7 +96,7 @@ function configureVue(previousConfig: ESLintConfig, options: Options): ESLintCon registeredComponentsOnly: false, }, ], - 'vue/html-self-closing': ['error'], + 'vue/html-self-closing': ['error', { html: { void: 'always' } }], 'vue/no-duplicate-attr-inheritance': ['error'], 'vue/no-empty-component-block': ['error'], 'vue/no-template-target-blank': ['error'],