Skip to content

Commit 268e6a9

Browse files
committed
Add prettier config
Change prettier config name to no-layout-rules
1 parent 9fdf8e0 commit 268e6a9

File tree

8 files changed

+86
-6
lines changed

8 files changed

+86
-6
lines changed

lib/configs/no-layout-rules.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* IMPORTANT!
3+
* This file has been automatically generated,
4+
* in order to update it's content execute "npm run update"
5+
*/
6+
module.exports = {
7+
rules: {
8+
'vue/html-closing-bracket-newline': 'off',
9+
'vue/html-closing-bracket-spacing': 'off',
10+
'vue/html-indent': 'off',
11+
'vue/html-quotes': 'off',
12+
'vue/html-self-closing': 'off',
13+
'vue/max-attributes-per-line': 'off',
14+
'vue/multiline-html-element-content-newline': 'off',
15+
'vue/mustache-interpolation-spacing': 'off',
16+
'vue/no-multi-spaces': 'off',
17+
'vue/no-spaces-around-equal-signs-in-attribute': 'off',
18+
'vue/script-indent': 'off',
19+
'vue/singleline-html-element-content-newline': 'off'
20+
}
21+
}

lib/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ module.exports = {
7373
configs: {
7474
'base': require('./configs/base'),
7575
'essential': require('./configs/essential'),
76-
'strongly-recommended': require('./configs/strongly-recommended'),
77-
'recommended': require('./configs/recommended')
76+
'no-layout-rules': require('./configs/no-layout-rules'),
77+
'recommended': require('./configs/recommended'),
78+
'strongly-recommended': require('./configs/strongly-recommended')
7879
},
7980
processors: {
8081
'.vue': require('./processor')

lib/rules/v-bind-style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const utils = require('../utils')
1717

1818
module.exports = {
1919
meta: {
20-
type: 'layout',
20+
type: 'suggestion',
2121
docs: {
2222
description: 'enforce `v-bind` directive style',
2323
category: 'strongly-recommended',

lib/rules/v-on-style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const utils = require('../utils')
1717

1818
module.exports = {
1919
meta: {
20-
type: 'layout',
20+
type: 'suggestion',
2121
docs: {
2222
description: 'enforce `v-on` directive style',
2323
category: 'strongly-recommended',

tools/lib/configs.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @author Michał Sajnóg <https://github.com/michalsnik>
3+
* See LICENSE file in root directory for full license.
4+
*/
5+
6+
'use strict'
7+
8+
const fs = require('fs')
9+
const path = require('path')
10+
const ROOT = path.resolve(__dirname, '../../lib/configs')
11+
12+
module.exports =
13+
fs.readdirSync(ROOT)
14+
.filter(file => path.extname(file) === '.js')
15+
.map(file => path.basename(file, '.js'))

tools/update-lib-index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const fs = require('fs')
1313
const path = require('path')
1414
const eslint = require('eslint')
1515
const rules = require('./lib/rules')
16-
const categories = require('./lib/categories')
16+
const configs = require('./lib/configs')
1717

1818
// Update files.
1919
const filePath = path.resolve(__dirname, '../lib/index.js')
@@ -29,7 +29,7 @@ module.exports = {
2929
${rules.map(rule => `'${rule.name}': require('./rules/${rule.name}')`).join(',\n')}
3030
},
3131
configs: {
32-
${categories.map(category => `'${category.categoryId}': require('./configs/${category.categoryId}')`).join(',\n')}
32+
${configs.map(config => `'${config}': require('./configs/${config}')`).join(',\n')}
3333
},
3434
processors: {
3535
'.vue': require('./processor')
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* @author Michał Sajnóg
3+
* @copyright 2018 Michał Sajnóg. All rights reserved.
4+
* See LICENSE file in root directory for full license.
5+
*/
6+
'use strict'
7+
8+
/*
9+
* This script updates `lib/configs/prettier.js`,
10+
* and disables all layout rules
11+
*/
12+
13+
const fs = require('fs')
14+
const path = require('path')
15+
const rules = require('./lib/rules')
16+
17+
const rulesToDisable = rules.filter(({ meta }) => meta.type === 'layout')
18+
19+
function formatRules (rules) {
20+
const obj = rules.reduce((setting, rule) => {
21+
setting[rule.ruleId] = 'off'
22+
return setting
23+
}, {})
24+
return JSON.stringify(obj, null, 2)
25+
}
26+
27+
function generateConfig (rules) {
28+
return `/*
29+
* IMPORTANT!
30+
* This file has been automatically generated,
31+
* in order to update it's content execute "npm run update"
32+
*/
33+
module.exports = {
34+
rules: ${formatRules(rules)}
35+
}
36+
`
37+
}
38+
39+
// Update files.
40+
const filePath = path.resolve(__dirname, '../lib/configs/no-layout-rules.js')
41+
const content = generateConfig(rulesToDisable)
42+
fs.writeFileSync(filePath, content)

tools/update.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
'use strict'
77

8+
require('./update-no-layout-rules-config')
89
require('./update-lib-configs')
910
require('./update-lib-index')
1011
require('./update-docs')

0 commit comments

Comments
 (0)