Skip to content

Commit

Permalink
Merge pull request #70 from crgwbr/crweber/vue-linting
Browse files Browse the repository at this point in the history
feat: add linting rules for Vue components
  • Loading branch information
onebytegone authored Nov 11, 2021
2 parents f72433c + 2a18ccb commit 39acc37
Show file tree
Hide file tree
Showing 4 changed files with 315 additions and 8 deletions.
10 changes: 9 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ module.exports = function(grunt) {
pkg: grunt.file.readJSON('package.json'),

eslint: {
target: [ '**/*.js', '!node_modules/**/*' ],
target: {
src: [ '**/*.js', '!node_modules/**/*' ],
},
fix: {
src: [ '**/*.js', '!node_modules/**/*' ],
options: {
fix: true,
},
},
},

});
Expand Down
198 changes: 198 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@

'use strict';

const vueRulesBase = require('eslint-plugin-vue/lib/configs/base').rules,
vueRulesEssentials = require('eslint-plugin-vue/lib/configs/essential').rules,
vue3RulesEssentials = require('eslint-plugin-vue/lib/configs/vue3-essential').rules,
vueRulesStronglyRecommended = require('eslint-plugin-vue/lib/configs/strongly-recommended').rules,
vue3RulesStronglyRecommended = require('eslint-plugin-vue/lib/configs/vue3-strongly-recommended').rules,
vueRulesRecommended = require('eslint-plugin-vue/lib/configs/recommended').rules,
vue3RulesRecommended = require('eslint-plugin-vue/lib/configs/vue3-recommended').rules;


module.exports = {

'extends': 'eslint:recommended',

'plugins': [
'@silvermine/eslint-plugin-silvermine', // Our custom rules
'@typescript-eslint', // TypeScript-specific rules
'vue', // Vue-specific rules
],

'parserOptions': {
Expand Down Expand Up @@ -334,5 +344,193 @@ module.exports = {
'@typescript-eslint/no-empty-interface': 'off',
},
},
{
files: [ '**/*.vue' ],
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 2020,
sourceType: 'module',
},
env: {
browser: true,
},
rules: Object.assign(
{},
vueRulesBase,
vueRulesEssentials,
vue3RulesEssentials,
vueRulesStronglyRecommended,
vue3RulesStronglyRecommended,
vueRulesRecommended,
vue3RulesRecommended,
{
// The 'no-unused-vars' rules does not work with type definitions in .vue
// files.
'no-unused-vars': 'off',

// Priority B: Strongly Recommended
'vue/attribute-hyphenation': [ 'error', 'never' ],
'vue/component-definition-name-casing': [ 'error', 'PascalCase' ],
'vue/html-closing-bracket-newline': [
'error',
{
'singleline': 'never',
'multiline': 'never',
},
],
'vue/html-closing-bracket-spacing': [
'error',
{
'startTag': 'never',
'endTag': 'never',
'selfClosingTag': 'always',
},
],
'vue/html-end-tags': 'error',
'vue/html-indent': [
'error',
3,
{
'attribute': 1,
'baseIndent': 1,
'closeBracket': 0,
'alignAttributesVertically': true,
},
],
'vue/html-quotes': [ 'error', 'double' ],
'vue/html-self-closing': 'error',
'vue/max-attributes-per-line': 'off',
'vue/multiline-html-element-content-newline': 'error',
'vue/mustache-interpolation-spacing': 'error',
'vue/no-multi-spaces': 'error',
'vue/no-spaces-around-equal-signs-in-attribute': 'error',
'vue/no-template-shadow': 'error',
'vue/one-component-per-file': 'error',
'vue/prop-name-casing': 'error',
'vue/require-default-prop': 'error',
'vue/require-prop-types': 'error',
'vue/singleline-html-element-content-newline': 'off',
'vue/v-bind-style': 'error',
'vue/v-on-style': 'error',
'vue/v-slot-style': 'error',

// Priority C: Recommended
'vue/attributes-order': 'off',
'vue/component-tags-order': [
'error',
{
'order': [ 'template', 'script', 'style' ],
},
],
'vue/no-lone-template': 'error',
'vue/no-multiple-slot-args': 'error',
'vue/no-v-html': 'off',
'vue/order-in-components': 'error',
'vue/this-in-template': 'error',

// Uncategorized
'vue/block-tag-newline': [
'error',
{
'singleline': 'always',
'multiline': 'always',
'maxEmptyLines': 0,
},
],
'vue/component-name-in-template-casing': 'error',
'vue/custom-event-name-casing': [ 'error', 'camelCase' ],
'vue/html-button-has-type': 'error',
'vue/html-comment-content-newline': 'error',
'vue/html-comment-content-spacing': 'error',
'vue/html-comment-indent': [ 'error', 3 ],
'vue/match-component-file-name': [
'error',
{
'extensions': [ 'vue' ],
'shouldMatchCase': true,
},
],
// 'vue/new-line-between-multi-line-property': 'off',
// 'vue/next-tick-style': 'off',
// 'vue/no-bare-strings-in-template': 'off',
// 'vue/no-boolean-default': 'off',
'vue/no-deprecated-v-is': 'error',
'vue/no-duplicate-attr-inheritance': 'error',
// 'vue/no-empty-component-block': 'off',
'vue/no-invalid-model-keys': 'error',
'vue/no-multiple-objects-in-class': 'error',
'vue/no-multiple-template-root': 'off',
'vue/no-potential-component-option-typo': 'error',
'vue/no-reserved-component-names': [
'error',
{
'disallowVueBuiltInComponents': true,
'disallowVue3BuiltInComponents': true,
},
],
// 'vue/no-restricted-block': 'off',
// 'vue/no-restricted-call-after-await': 'off',
// 'vue/no-restricted-component-options': 'off',
// 'vue/no-restricted-custom-event': 'off',
// 'vue/no-restricted-props': 'off',
// 'vue/no-restricted-static-attribute': 'off',
// 'vue/no-restricted-v-bind': 'off',
// 'vue/no-static-inline-styles': 'off',
// 'vue/no-template-target-blank': 'TODO',
'vue/no-this-in-before-route-enter': 'error',
// 'vue/no-unregistered-components': 'off',
// 'vue/no-unsupported-features': 'TODO',
// 'vue/no-unused-properties': 'TODO',
// 'vue/no-useless-mustaches': 'TODO',
// 'vue/no-useless-v-bind': 'TODO',
// 'vue/padding-line-between-blocks': 'TODO',
// 'vue/require-direct-export': 'TODO',
'vue/require-emit-validator': 'error',
// 'vue/require-name-property': 'TODO',
// 'vue/script-indent': 'TODO',
// 'vue/sort-keys': 'TODO',
// 'vue/static-class-names-order': 'TODO',
// 'vue/v-for-delimiter-style': 'TODO',
// 'vue/v-on-event-hyphenation': 'TODO',
// 'vue/v-on-function-call': 'TODO',
// 'vue/valid-next-tick': 'TODO',

// Extension Rules
// 'vue/array-bracket-newline': 'TODO',
// 'vue/array-bracket-spacing': 'TODO',
// 'vue/arrow-spacing': 'TODO',
// 'vue/block-spacing': 'TODO',
// 'vue/brace-style': 'TODO',
// 'vue/camelcase': 'TODO',
// 'vue/comma-dangle': 'TODO',
// 'vue/comma-spacing': 'TODO',
// 'vue/comma-style': 'TODO',
// 'vue/dot-location': 'TODO',
// 'vue/dot-notation': 'TODO',
// 'vue/eqeqeq': 'TODO',
// 'vue/func-call-spacing': 'TODO',
// 'vue/key-spacing': 'TODO',
// 'vue/keyword-spacing': 'TODO',
// 'vue/max-len': 'TODO',
// 'vue/no-constant-condition': 'TODO',
// 'vue/no-empty-pattern': 'TODO',
// 'vue/no-extra-parens': 'TODO',
// 'vue/no-irregular-whitespace': 'TODO',
// 'vue/no-restricted-syntax': 'TODO',
// 'vue/no-sparse-arrays': 'TODO',
// 'vue/no-useless-concat': 'TODO',
// 'vue/object-curly-newline': 'TODO',
// 'vue/object-curly-spacing': 'TODO',
// 'vue/object-property-newline': 'TODO',
// 'vue/operator-linebreak': 'TODO',
// 'vue/prefer-template': 'TODO',
// 'vue/space-in-parens': 'TODO',
// 'vue/space-infix-ops': 'TODO',
// 'vue/space-unary-ops': 'TODO',
// 'vue/template-curly-spacing': 'TODO',
}
),
},
],
};
114 changes: 107 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@silvermine/eslint-plugin-silvermine": "2.3.1",
"@typescript-eslint/eslint-plugin": "2.16.0",
"@typescript-eslint/parser": "2.16.0",
"eslint-plugin-vue": "7.11.1",
"typescript": "3.3.1"
},
"devDependencies": {
Expand Down

0 comments on commit 39acc37

Please sign in to comment.