-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstylelint.config.js
72 lines (68 loc) · 2.62 KB
/
stylelint.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* 自定义的StyleLint配置项
* 规则中文 @see http://stylelint.cn/user-guide/rules/
* 规则英文 @see https://stylelint.io/user-guide/rules/
*
* 使用注释自定义规则 @see https://github.com/stylelint/stylelint/blob/master/docs/user-guide/configuration.md#turning-rules-off-from-within-your-css
*/
/**
* StyleLint的插件需要配置 configBaseDir
* 全局的插件安装用于编辑器的使用
* 局部的安装用于webpack的使用
* @type {String}
*/
let NODE_DIR = '/usr/local/lib/node_modules/';
if (process.platform === 'win32') {
NODE_DIR = 'C:/Users/e470/AppData/Roaming/npm/node_modules/';
}
if (process.argv && process.argv.some(item => {
return item.includes('webpack.config');
})) {
NODE_DIR = '';
}
module.exports = {
// 以此规则集为基础
extends: [
// 默认规则 @see https://github.com/stylelint/stylelint-config-standard/blob/master/index.js
NODE_DIR + 'stylelint-config-standard'
],
// 检查html文件(或tpl文件)中的CSS
processors: [
// NODE_DIR + 'postcss-html',
// NODE_DIR + 'stylelint-processor-html',
// NODE_DIR + '@mapbox/stylelint-processor-arbitrary-tags'
],
// 自定义的规则
rules: {
// 颜色值避免直接使用颜色名
'color-named': [
'never', {
ignore: ['inside-function']
}
],
// 使用数字或命名的 (可能的情况下) font-weight 值
'font-weight-notation': 'numeric',
// 在函数的逗号之后要求有一个换行符或禁止有空白
'function-comma-newline-after': null,
// 在函数的括号内要求有一个换行符或禁止有空白
'function-parentheses-newline-inside': null,
// url使用引号
'function-url-quotes': 'always',
// 禁止小于 1 的小数的前导 0
'number-leading-zero': 'never',
// 字符串使用双引号
'string-quotes': 'double',
// 要求选择器列表的逗号之前有一个换行符
'selector-list-comma-newline-before': 'never-multi-line',
// 在媒体查询的逗号之前禁止有一换行
'media-query-list-comma-newline-before': 'never-multi-line',
// 缩进
'indentation': 4,
// 禁止低优先级的选择器出现在高优先级的选择器之后
'no-descending-specificity': null,
// 禁止空源
'no-empty-source': null,
// 禁止缺少文件末尾的换行符
'no-missing-end-of-source-newline': null
}
};