diff --git a/docs/rules/html-indent.md b/docs/rules/html-indent.md new file mode 100644 index 000000000..9786c3b13 --- /dev/null +++ b/docs/rules/html-indent.md @@ -0,0 +1,41 @@ +# Enforce consistent indentation in html template (html-indent) + +Please describe the origin of the rule here. + +## :book: Rule Details + +This rule aims to... + +Examples of **incorrect** code for this rule: + +```html + +``` + +Examples of **correct** code for this rule: + +```html + +``` + +## :wrench: Options + +This rule has a mixed option: + +For example, for 2-space indentation: + +``` +vue/html-indent: [2, 2] +``` + +Or for tabbed indentation: + +``` +vue/html-indent: [2, 'tab'] +``` diff --git a/lib/rules/html-indent.js b/lib/rules/html-indent.js new file mode 100644 index 000000000..973d6a6d2 --- /dev/null +++ b/lib/rules/html-indent.js @@ -0,0 +1,53 @@ +/** + * @fileoverview Enforce consistent indentation in html template + * @author Armano + */ +'use strict' + +// ------------------------------------------------------------------------------ +// Rule Definition +// ------------------------------------------------------------------------------ + +function create (context) { + // variables should be defined here + + // ---------------------------------------------------------------------- + // Helpers + // ---------------------------------------------------------------------- + + // any helper functions should go here or else delete this section + + // ---------------------------------------------------------------------- + // Public + // ---------------------------------------------------------------------- + + return { + // give me methods + } +} + +module.exports = { + meta: { + docs: { + description: 'Enforce consistent indentation in html template', + category: 'Stylistic Issues', + recommended: false + }, + fixable: null, // or "code" or "whitespace" + schema: [ + { + oneOf: [ + { + enum: ['tab'] + }, + { + type: 'integer', + minimum: 0 + } + ] + } + ] + }, + + create +} diff --git a/tests/lib/rules/html-indent.js b/tests/lib/rules/html-indent.js new file mode 100644 index 000000000..9e8c2203b --- /dev/null +++ b/tests/lib/rules/html-indent.js @@ -0,0 +1,34 @@ +/** + * @fileoverview Enforce consistent indentation in html template + * @author Armano + */ +'use strict' + +// ------------------------------------------------------------------------------ +// Requirements +// ------------------------------------------------------------------------------ + +const rule = require('../../../lib/rules/html-indent') +const RuleTester = require('eslint').RuleTester + +// ------------------------------------------------------------------------------ +// Tests +// ------------------------------------------------------------------------------ + +const ruleTester = new RuleTester() +ruleTester.run('html-indent', rule, { + + valid: [ + // give me some code that won't trigger a warning + ], + + invalid: [ + { + code: '', + errors: [{ + message: 'Fill me in.', + type: 'Me too' + }] + } + ] +})