@huangjunsen/stylelint-config 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +15 -0
- package/index.js +20 -0
- package/package.json +4 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @huangjunsen/stylelint-config
|
|
2
|
+
|
|
3
|
+
## 1.0.5
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 新增 Vue 单文件组件支持:内置 `postcss-html` 并为 `**/*.vue` 配置 `customSyntax`,此前 `.vue` 中的 `<template>` 插值会被当作 CSS 解析,直接报 `CssSyntaxError`,表现为「Vue 项目的样式完全无法检查」
|
|
8
|
+
- `customSyntax` 使用 `require.resolve` 得到的绝对路径:stylelint 16 起裸模块名会从 stylelint 自身安装目录解析,绝对路径才稳定可用
|
|
9
|
+
|
|
10
|
+
## 1.0.4
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 补齐完整的版本变更记录,并将 CHANGELOG 纳入发布内容
|
|
15
|
+
|
|
16
|
+
## 1.0.3
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- 升级至 stylelint 17:`stylelint-config-standard` 34 → 40、`stylelint-config-standard-scss` 11 → 17、`stylelint-scss` 5 → 7
|
|
21
|
+
- `peerDependencies` 放宽为 `^16.0.0 || ^17.0.0`
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 移除 stylelint 16 起已删除的排版与空白类规则(`indentation`、`max-line-length`、`no-extra-semicolons`、`block-*-brace-*`、`declaration-block-trailing-semicolon`、`value-list-comma-space-after` 等),避免 `Unknown rule` 报错
|
|
26
|
+
- 测试运行器改用 Jest 30 + `--experimental-vm-modules` 以加载纯 ESM 的 stylelint
|
|
27
|
+
- 新增配置有效性测试,断言规则均存在且未声明已移除的排版规则
|
|
28
|
+
- 重写 README
|
|
29
|
+
|
|
30
|
+
## 1.0.2
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- 补充 `stylelint` peerDependencies 与发布文件声明
|
|
35
|
+
|
|
36
|
+
## 1.0.1
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- 修复脚手架场景下缺少 `configBasedir` 导致的 `extends` 解析失败
|
|
41
|
+
|
|
42
|
+
## 1.0.0
|
|
43
|
+
|
|
44
|
+
### Minor Changes
|
|
45
|
+
|
|
46
|
+
- 首个版本:继承 `stylelint-config-standard` 与 `stylelint-config-standard-scss`,并放宽支持小程序的 `rpx` 等自定义单位
|
package/README.md
CHANGED
|
@@ -4,6 +4,7 @@ CSS、SCSS、Less 样式代码的共享质量检查规范。
|
|
|
4
4
|
|
|
5
5
|
- 继承 `stylelint-config-standard` 与 `stylelint-config-standard-scss`;
|
|
6
6
|
- 禁止选择器重复、未知属性、简写属性覆盖详细属性等常见错误;
|
|
7
|
+
- 内置 `postcss-html`,**开箱支持 Vue 单文件组件的 `<style>` 块**;
|
|
7
8
|
- **国内移动端兼容**:放宽并支持小程序的 `rpx` 等自定义单位;
|
|
8
9
|
- 不含排版 / 空白类规则(缩进、换行、分号、行长度等统一交给 Prettier)。
|
|
9
10
|
|
|
@@ -41,6 +42,20 @@ module.exports = {
|
|
|
41
42
|
|
|
42
43
|
---
|
|
43
44
|
|
|
45
|
+
## Vue 项目
|
|
46
|
+
|
|
47
|
+
`.vue` 不是标准 CSS 语法,必须先由 `postcss-html` 取出 `<style>` 块,否则 stylelint 会把 `<template>` 里的插值当作 CSS 解析并报 `CssSyntaxError`。
|
|
48
|
+
|
|
49
|
+
本配置已内置该能力,无需再安装 `stylelint-config-html`,直接扫描 `.vue` 文件即可:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npx stylelint "src/**/*.{vue,css,scss,less}"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`customSyntax` 用的是 `require.resolve('postcss-html')` 得到的**绝对路径**:stylelint 16 起,配置中的裸模块名会从 stylelint 自身安装目录解析,只有绝对路径才稳定可用。
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
44
59
|
## stylelint 16 起的变更
|
|
45
60
|
|
|
46
61
|
stylelint 16 移除了全部**排版与空白类(stylistic)规则**,本配置同步清理,不再声明:
|
package/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue 单文件组件的 <style> 解析器
|
|
3
|
+
*
|
|
4
|
+
* 用 require.resolve 取绝对路径,避免 stylelint 从自身安装目录解析裸模块名而失败
|
|
5
|
+
*/
|
|
6
|
+
const postcssHtml = require.resolve('postcss-html');
|
|
7
|
+
|
|
1
8
|
module.exports = {
|
|
2
9
|
defaultSeverity: 'warning', // 设置所有规则的默认严重性级别。
|
|
3
10
|
plugins: ['stylelint-scss'], // 引入 stylelint-scss 插件,启用 SCSS 特定的规则。
|
|
@@ -71,5 +78,18 @@ module.exports = {
|
|
|
71
78
|
'scss/double-slash-comment-whitespace-inside': 'always', // SCSS 中双斜杠注释内必须有空白。
|
|
72
79
|
},
|
|
73
80
|
ignoreFiles: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'], // 指定 stylelint 忽略的文件类型。
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Vue 单文件组件支持
|
|
84
|
+
*
|
|
85
|
+
* .vue 不是标准 CSS 语法,必须先由 postcss-html 取出 <style> 块,
|
|
86
|
+
* 否则 stylelint 会报 CssSyntaxError(把模板里的插值当成 CSS 解析)。
|
|
87
|
+
*/
|
|
88
|
+
overrides: [
|
|
89
|
+
{
|
|
90
|
+
files: ['**/*.vue'],
|
|
91
|
+
customSyntax: postcssHtml,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
74
94
|
};
|
|
75
95
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huangjunsen/stylelint-config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "CSS规范",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"encode",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"index.js",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"README.md",
|
|
20
|
+
"CHANGELOG.md"
|
|
21
21
|
],
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"url": "https://github.com/huangjunsen0406/js-encode-fe-spec/issues"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
+
"postcss-html": "^2.0.0",
|
|
30
31
|
"stylelint-config-standard": "^40.0.0",
|
|
31
32
|
"stylelint-config-standard-scss": "^17.0.0",
|
|
32
33
|
"stylelint-scss": "^7.2.0"
|