diff --git a/.eslintrc.js b/.eslintrc.js index b8f76a4f4..35e09ba8f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -30,6 +30,7 @@ module.exports = { rules: { "consistent-docs-description": "error", "no-invalid-meta": "error", + 'eslint-plugin/require-meta-type': 'error', "require-meta-docs-url": ["error", { "pattern": `https://github.com/vuejs/eslint-plugin-vue/blob/v${version}/docs/rules/{{name}}.md` }] diff --git a/lib/configs/no-layout-rules.js b/lib/configs/no-layout-rules.js new file mode 100644 index 000000000..052301e5f --- /dev/null +++ b/lib/configs/no-layout-rules.js @@ -0,0 +1,21 @@ +/* + * IMPORTANT! + * This file has been automatically generated, + * in order to update it's content execute "npm run update" + */ +module.exports = { + rules: { + 'vue/html-closing-bracket-newline': 'off', + 'vue/html-closing-bracket-spacing': 'off', + 'vue/html-indent': 'off', + 'vue/html-quotes': 'off', + 'vue/html-self-closing': 'off', + 'vue/max-attributes-per-line': 'off', + 'vue/multiline-html-element-content-newline': 'off', + 'vue/mustache-interpolation-spacing': 'off', + 'vue/no-multi-spaces': 'off', + 'vue/no-spaces-around-equal-signs-in-attribute': 'off', + 'vue/script-indent': 'off', + 'vue/singleline-html-element-content-newline': 'off' + } +} diff --git a/lib/index.js b/lib/index.js index 5952af45a..e6086ac98 100644 --- a/lib/index.js +++ b/lib/index.js @@ -73,8 +73,9 @@ module.exports = { configs: { 'base': require('./configs/base'), 'essential': require('./configs/essential'), - 'strongly-recommended': require('./configs/strongly-recommended'), - 'recommended': require('./configs/recommended') + 'no-layout-rules': require('./configs/no-layout-rules'), + 'recommended': require('./configs/recommended'), + 'strongly-recommended': require('./configs/strongly-recommended') }, processors: { '.vue': require('./processor') diff --git a/lib/rules/v-bind-style.js b/lib/rules/v-bind-style.js index 328e14988..44dc4db9f 100644 --- a/lib/rules/v-bind-style.js +++ b/lib/rules/v-bind-style.js @@ -17,7 +17,7 @@ const utils = require('../utils') module.exports = { meta: { - type: 'layout', + type: 'suggestion', docs: { description: 'enforce `v-bind` directive style', category: 'strongly-recommended', diff --git a/lib/rules/v-on-style.js b/lib/rules/v-on-style.js index 6dbb6919f..8a3573266 100644 --- a/lib/rules/v-on-style.js +++ b/lib/rules/v-on-style.js @@ -17,7 +17,7 @@ const utils = require('../utils') module.exports = { meta: { - type: 'layout', + type: 'suggestion', docs: { description: 'enforce `v-on` directive style', category: 'strongly-recommended', diff --git a/package.json b/package.json index f00a94c08..a5df0c1dc 100644 --- a/package.json +++ b/package.json @@ -53,8 +53,8 @@ "@types/node": "^4.2.16", "babel-eslint": "^8.2.2", "chai": "^4.1.0", - "eslint": "^5.2.0", - "eslint-plugin-eslint-plugin": "^1.4.0", + "eslint": "^5.11.1", + "eslint-plugin-eslint-plugin": "^2.0.1", "eslint-plugin-vue-libs": "^3.0.0", "eslint4b": "^5.1.0", "lodash": "^4.17.4", diff --git a/tools/lib/configs.js b/tools/lib/configs.js new file mode 100644 index 000000000..3eedc5422 --- /dev/null +++ b/tools/lib/configs.js @@ -0,0 +1,15 @@ +/** + * @author Michał Sajnóg + * See LICENSE file in root directory for full license. + */ + +'use strict' + +const fs = require('fs') +const path = require('path') +const ROOT = path.resolve(__dirname, '../../lib/configs') + +module.exports = + fs.readdirSync(ROOT) + .filter(file => path.extname(file) === '.js') + .map(file => path.basename(file, '.js')) diff --git a/tools/update-lib-index.js b/tools/update-lib-index.js index faeb32f33..742b10a02 100644 --- a/tools/update-lib-index.js +++ b/tools/update-lib-index.js @@ -13,7 +13,7 @@ const fs = require('fs') const path = require('path') const eslint = require('eslint') const rules = require('./lib/rules') -const categories = require('./lib/categories') +const configs = require('./lib/configs') // Update files. const filePath = path.resolve(__dirname, '../lib/index.js') @@ -29,7 +29,7 @@ module.exports = { ${rules.map(rule => `'${rule.name}': require('./rules/${rule.name}')`).join(',\n')} }, configs: { - ${categories.map(category => `'${category.categoryId}': require('./configs/${category.categoryId}')`).join(',\n')} + ${configs.map(config => `'${config}': require('./configs/${config}')`).join(',\n')} }, processors: { '.vue': require('./processor') diff --git a/tools/update-no-layout-rules-config.js b/tools/update-no-layout-rules-config.js new file mode 100644 index 000000000..f7b13e3ec --- /dev/null +++ b/tools/update-no-layout-rules-config.js @@ -0,0 +1,42 @@ +/** + * @author Michał Sajnóg + * @copyright 2018 Michał Sajnóg. All rights reserved. + * See LICENSE file in root directory for full license. + */ +'use strict' + +/* + * This script updates `lib/configs/prettier.js`, + * and disables all layout rules + */ + +const fs = require('fs') +const path = require('path') +const rules = require('./lib/rules') + +const rulesToDisable = rules.filter(({ meta }) => meta.type === 'layout') + +function formatRules (rules) { + const obj = rules.reduce((setting, rule) => { + setting[rule.ruleId] = 'off' + return setting + }, {}) + return JSON.stringify(obj, null, 2) +} + +function generateConfig (rules) { + return `/* + * IMPORTANT! + * This file has been automatically generated, + * in order to update it's content execute "npm run update" + */ +module.exports = { + rules: ${formatRules(rules)} +} +` +} + +// Update files. +const filePath = path.resolve(__dirname, '../lib/configs/no-layout-rules.js') +const content = generateConfig(rulesToDisable) +fs.writeFileSync(filePath, content) diff --git a/tools/update.js b/tools/update.js index f6ec8751f..fc1e2e6bd 100644 --- a/tools/update.js +++ b/tools/update.js @@ -5,6 +5,7 @@ */ 'use strict' +require('./update-no-layout-rules-config') require('./update-lib-configs') require('./update-lib-index') require('./update-docs')