Skip to content

Chore: Add prettier config #698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 30, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/configs/no-layout-rules.js
Original file line number Diff line number Diff line change
@@ -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'
}
}
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/v-bind-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/v-on-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
15 changes: 15 additions & 0 deletions tools/lib/configs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @author Michał Sajnóg <https://github.com/michalsnik>
* 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'))
4 changes: 2 additions & 2 deletions tools/update-lib-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down
42 changes: 42 additions & 0 deletions tools/update-no-layout-rules-config.js
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions tools/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
'use strict'

require('./update-no-layout-rules-config')
require('./update-lib-configs')
require('./update-lib-index')
require('./update-docs')
Expand Down