@css-modules-kit/stylelint-plugin 0.1.0 → 0.2.0
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/README.md +2 -7
- package/dist/recommended.d.ts +4 -0
- package/dist/recommended.d.ts.map +1 -0
- package/dist/recommended.js +43 -0
- package/dist/recommended.js.map +1 -0
- package/dist/rules/no-missing-component-file.js +1 -1
- package/dist/rules/no-missing-component-file.js.map +1 -1
- package/dist/rules/no-unused-class-names.js +1 -1
- package/dist/rules/no-unused-class-names.js.map +1 -1
- package/package.json +16 -3
- package/src/recommended.ts +45 -0
- package/src/rules/no-missing-component-file.ts +3 -3
- package/src/rules/no-unused-class-names.ts +3 -3
package/README.md
CHANGED
|
@@ -14,15 +14,10 @@ npm i -D @css-modules-kit/stylelint-plugin
|
|
|
14
14
|
// stylelint.config.js
|
|
15
15
|
/** @type {import('stylelint').Config} */
|
|
16
16
|
export default {
|
|
17
|
-
|
|
18
|
-
rules: {
|
|
19
|
-
'css-modules-kit/no-unused-class-names': true,
|
|
20
|
-
'css-modules-kit/no-missing-component-file': true,
|
|
21
|
-
},
|
|
17
|
+
extends: ['@css-modules-kit/stylelint-plugin/recommended'],
|
|
22
18
|
};
|
|
23
19
|
```
|
|
24
20
|
|
|
25
21
|
## Rules
|
|
26
22
|
|
|
27
|
-
-
|
|
28
|
-
- `css-modules-kit/no-missing-component-file`
|
|
23
|
+
The same rules as eslint-plugin are provided. See [the eslint-plugin documentation](https://github.com/mizdra/css-modules-kit/blob/main/packages/eslint-plugin/README.md#rules) for a list of rules.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended.d.ts","sourceRoot":"","sources":["../src/recommended.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,QAAA,MAAM,iBAAiB,EAAE,MAwCxB,CAAC;AAEF,SAAS,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const recommendedConfig = {
|
|
3
|
+
plugins: ['@css-modules-kit/stylelint-plugin'],
|
|
4
|
+
languageOptions: {
|
|
5
|
+
syntax: {
|
|
6
|
+
atRules: {
|
|
7
|
+
value: {
|
|
8
|
+
// Example:
|
|
9
|
+
// - `@value a: #123;`
|
|
10
|
+
// - `@value empty:;`
|
|
11
|
+
// - `@value withoutSemicolon #123;`
|
|
12
|
+
// - `@value a from './test.module.css';`
|
|
13
|
+
// - `@value a, b from './test.module.css';`
|
|
14
|
+
// - `@value a as aliased_a from './test.module.css';`
|
|
15
|
+
//
|
|
16
|
+
// CSS Modules Kit does not support the following for implementation simplicity:
|
|
17
|
+
// - `@value (a, b) from '...';`
|
|
18
|
+
// - `@value a from moduleName;`
|
|
19
|
+
//
|
|
20
|
+
// ref: https://github.com/css-modules/postcss-icss-values/blob/acdf34a62cc2537a9507b1e9fd34db486e5cb0f8/test/test.js
|
|
21
|
+
prelude: '<custom-ident> :? <declaration-value>? | [ [ <custom-ident> [ as <custom-ident> ]? ]# from <string> ]',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
properties: {
|
|
25
|
+
// Example:
|
|
26
|
+
// - `composes: a;`
|
|
27
|
+
// - `composes: a from './test.module.css';`
|
|
28
|
+
// - `composes: a, b from './test.module.css';`
|
|
29
|
+
// - `composes: a b from './test.module.css';`
|
|
30
|
+
// - `composes: global(a) from './test.module.css';`
|
|
31
|
+
//
|
|
32
|
+
// ref: https://github.com/css-modules/postcss-modules-extract-imports/blob/16f9c570e517cf3558b88cf96dcadf794230965a/src/index.js
|
|
33
|
+
composes: '[ [ <custom-ident> | global(<custom-ident>) ] ,? ]+ [ from <string> ]?',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
rules: {
|
|
38
|
+
'css-modules-kit/no-unused-class-names': true,
|
|
39
|
+
'css-modules-kit/no-missing-component-file': true,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
module.exports = recommendedConfig;
|
|
43
|
+
//# sourceMappingURL=recommended.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../src/recommended.ts"],"names":[],"mappings":";AAEA,MAAM,iBAAiB,GAAW;IAChC,OAAO,EAAE,CAAC,mCAAmC,CAAC;IAC9C,eAAe,EAAE;QACf,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,WAAW;oBACX,sBAAsB;oBACtB,qBAAqB;oBACrB,oCAAoC;oBACpC,yCAAyC;oBACzC,4CAA4C;oBAC5C,sDAAsD;oBACtD,EAAE;oBACF,gFAAgF;oBAChF,gCAAgC;oBAChC,gCAAgC;oBAChC,EAAE;oBACF,qHAAqH;oBACrH,OAAO,EACL,uGAAuG;iBAC1G;aACF;YACD,UAAU,EAAE;gBACV,WAAW;gBACX,mBAAmB;gBACnB,4CAA4C;gBAC5C,+CAA+C;gBAC/C,8CAA8C;gBAC9C,oDAAoD;gBACpD,EAAE;gBACF,iIAAiI;gBACjI,QAAQ,EAAE,wEAAwE;aACnF;SACF;KACF;IACD,KAAK,EAAE;QACL,uCAAuC,EAAE,IAAI;QAC7C,2CAA2C,EAAE,IAAI;KAClD;CACF,CAAC;AAEF,iBAAS,iBAAiB,CAAC"}
|
|
@@ -13,7 +13,7 @@ const messages = utils.ruleMessages(ruleName, {
|
|
|
13
13
|
disallow: () => `The corresponding component file is not found.`,
|
|
14
14
|
});
|
|
15
15
|
const meta = {
|
|
16
|
-
url: 'https://github.com/mizdra/css-modules-kit/blob/main/packages/
|
|
16
|
+
url: 'https://github.com/mizdra/css-modules-kit/blob/main/packages/eslint-plugin/docs/rules/no-missing-component-file.md',
|
|
17
17
|
};
|
|
18
18
|
const ruleFunction = (_primaryOptions, _secondaryOptions, _context) => {
|
|
19
19
|
return async (root, result) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-missing-component-file.js","sourceRoot":"","sources":["../../src/rules/no-missing-component-file.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA2E;AAE3E,0DAAkC;AAClC,wCAAsC;AAEtC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,mBAAS,CAAC;AAE1C,MAAM,QAAQ,GAAG,2CAA2C,CAAC;AAE7D,MAAM,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE;IAC5C,QAAQ,EAAE,GAAG,EAAE,CAAC,gDAAgD;CACjE,CAAC,CAAC;AAEH,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"no-missing-component-file.js","sourceRoot":"","sources":["../../src/rules/no-missing-component-file.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA2E;AAE3E,0DAAkC;AAClC,wCAAsC;AAEtC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,mBAAS,CAAC;AAE1C,MAAM,QAAQ,GAAG,2CAA2C,CAAC;AAE7D,MAAM,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE;IAC5C,QAAQ,EAAE,GAAG,EAAE,CAAC,gDAAgD;CACjE,CAAC,CAAC;AAEH,MAAM,IAAI,GAAa;IACrB,GAAG,EAAE,oHAAoH;CAC1H,CAAC;AAEF,MAAM,YAAY,GAAS,CAAC,eAAe,EAAE,iBAAiB,EAAE,QAAQ,EAAE,EAAE;IAC1E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC;QACzC,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,IAAA,sBAAe,EAAC,QAAQ,CAAC;YAAE,OAAO;QAEjE,MAAM,aAAa,GAAG,MAAM,IAAA,wBAAiB,EAAC,QAAQ,EAAE,kBAAQ,CAAC,CAAC;QAElE,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;YAChC,KAAK,CAAC,MAAM,CAAC;gBACX,MAAM;gBACN,QAAQ;gBACR,OAAO,EAAE,QAAQ,CAAC,QAAQ,EAAE;gBAC5B,IAAI,EAAE,IAAI;gBACV,KAAK,EAAE,CAAC;gBACR,QAAQ,EAAE,CAAC;aACZ,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACjC,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACjC,YAAY,CAAC,IAAI,GAAG,IAAI,CAAC;AAEZ,QAAA,sBAAsB,GAAG,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC"}
|
|
@@ -13,7 +13,7 @@ const messages = utils.ruleMessages(ruleName, {
|
|
|
13
13
|
disallow: (className, componentFileName) => `"${className}" is defined but never used in "${(0, core_1.basename)(componentFileName)}"`,
|
|
14
14
|
});
|
|
15
15
|
const meta = {
|
|
16
|
-
url: 'https://github.com/mizdra/css-modules-kit/blob/main/packages/
|
|
16
|
+
url: 'https://github.com/mizdra/css-modules-kit/blob/main/packages/eslint-plugin/docs/rules/no-unused-class-names.md',
|
|
17
17
|
};
|
|
18
18
|
const ruleFunction = (_primaryOptions, _secondaryOptions, _context) => {
|
|
19
19
|
return async (root, result) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-unused-class-names.js","sourceRoot":"","sources":["../../src/rules/no-unused-class-names.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAoH;AAEpH,0DAAkC;AAClC,wCAAsC;AAEtC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,mBAAS,CAAC;AAE1C,MAAM,QAAQ,GAAG,uCAAuC,CAAC;AAEzD,MAAM,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE;IAC5C,QAAQ,EAAE,CAAC,SAAiB,EAAE,iBAAyB,EAAE,EAAE,CACzD,IAAI,SAAS,mCAAmC,IAA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EAAC,IAAI,CAAC,CAAC;YAE3C,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;gBAC3C,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC5C,KAAK,CAAC,MAAM,CAAC;wBACX,MAAM;wBACN,QAAQ;wBACR,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC;wBACtE,IAAI,EAAE,IAAI;wBACV,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM;wBACrC,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM;wBACtC,IAAI,EAAE,aAAa,CAAC,IAAI;qBACzB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACjC,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACjC,YAAY,CAAC,IAAI,GAAG,IAAI,CAAC;AAEZ,QAAA,kBAAkB,GAAG,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@css-modules-kit/stylelint-plugin",
|
|
3
3
|
"description": "A stylelint plugin for CSS Modules",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"repository": {
|
|
@@ -12,7 +12,20 @@
|
|
|
12
12
|
"author": "mizdra <pp.mizdra@gmail.com>",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"private": false,
|
|
15
|
-
"
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"./recommended": {
|
|
23
|
+
"import": {
|
|
24
|
+
"types": "./dist/recommended.d.ts",
|
|
25
|
+
"default": "./dist/recommended.js"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
16
29
|
"scripts": {
|
|
17
30
|
"build": "tsc -b tsconfig.build.json"
|
|
18
31
|
},
|
|
@@ -37,7 +50,7 @@
|
|
|
37
50
|
"dist"
|
|
38
51
|
],
|
|
39
52
|
"dependencies": {
|
|
40
|
-
"@css-modules-kit/core": "^0.
|
|
53
|
+
"@css-modules-kit/core": "^0.2.0"
|
|
41
54
|
},
|
|
42
55
|
"peerDependencies": {
|
|
43
56
|
"stylelint": "^16.0.0"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Config } from 'stylelint';
|
|
2
|
+
|
|
3
|
+
const recommendedConfig: Config = {
|
|
4
|
+
plugins: ['@css-modules-kit/stylelint-plugin'],
|
|
5
|
+
languageOptions: {
|
|
6
|
+
syntax: {
|
|
7
|
+
atRules: {
|
|
8
|
+
value: {
|
|
9
|
+
// Example:
|
|
10
|
+
// - `@value a: #123;`
|
|
11
|
+
// - `@value empty:;`
|
|
12
|
+
// - `@value withoutSemicolon #123;`
|
|
13
|
+
// - `@value a from './test.module.css';`
|
|
14
|
+
// - `@value a, b from './test.module.css';`
|
|
15
|
+
// - `@value a as aliased_a from './test.module.css';`
|
|
16
|
+
//
|
|
17
|
+
// CSS Modules Kit does not support the following for implementation simplicity:
|
|
18
|
+
// - `@value (a, b) from '...';`
|
|
19
|
+
// - `@value a from moduleName;`
|
|
20
|
+
//
|
|
21
|
+
// ref: https://github.com/css-modules/postcss-icss-values/blob/acdf34a62cc2537a9507b1e9fd34db486e5cb0f8/test/test.js
|
|
22
|
+
prelude:
|
|
23
|
+
'<custom-ident> :? <declaration-value>? | [ [ <custom-ident> [ as <custom-ident> ]? ]# from <string> ]',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
properties: {
|
|
27
|
+
// Example:
|
|
28
|
+
// - `composes: a;`
|
|
29
|
+
// - `composes: a from './test.module.css';`
|
|
30
|
+
// - `composes: a, b from './test.module.css';`
|
|
31
|
+
// - `composes: a b from './test.module.css';`
|
|
32
|
+
// - `composes: global(a) from './test.module.css';`
|
|
33
|
+
//
|
|
34
|
+
// ref: https://github.com/css-modules/postcss-modules-extract-imports/blob/16f9c570e517cf3558b88cf96dcadf794230965a/src/index.js
|
|
35
|
+
composes: '[ [ <custom-ident> | global(<custom-ident>) ] ,? ]+ [ from <string> ]?',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
rules: {
|
|
40
|
+
'css-modules-kit/no-unused-class-names': true,
|
|
41
|
+
'css-modules-kit/no-missing-component-file': true,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export = recommendedConfig;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { findComponentFile, isCSSModuleFile } from '@css-modules-kit/core';
|
|
2
|
-
import type { Rule } from 'stylelint';
|
|
2
|
+
import type { Rule, RuleMeta } from 'stylelint';
|
|
3
3
|
import stylelint from 'stylelint';
|
|
4
4
|
import { readFile } from '../util.js';
|
|
5
5
|
|
|
@@ -11,8 +11,8 @@ const messages = utils.ruleMessages(ruleName, {
|
|
|
11
11
|
disallow: () => `The corresponding component file is not found.`,
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
const meta = {
|
|
15
|
-
url: 'https://github.com/mizdra/css-modules-kit/blob/main/packages/
|
|
14
|
+
const meta: RuleMeta = {
|
|
15
|
+
url: 'https://github.com/mizdra/css-modules-kit/blob/main/packages/eslint-plugin/docs/rules/no-missing-component-file.md',
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const ruleFunction: Rule = (_primaryOptions, _secondaryOptions, _context) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { basename, findComponentFile, findUsedTokenNames, isCSSModuleFile, parseRule } from '@css-modules-kit/core';
|
|
2
|
-
import type { Rule } from 'stylelint';
|
|
2
|
+
import type { Rule, RuleMeta } from 'stylelint';
|
|
3
3
|
import stylelint from 'stylelint';
|
|
4
4
|
import { readFile } from '../util.js';
|
|
5
5
|
|
|
@@ -12,8 +12,8 @@ const messages = utils.ruleMessages(ruleName, {
|
|
|
12
12
|
`"${className}" is defined but never used in "${basename(componentFileName)}"`,
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
const meta = {
|
|
16
|
-
url: 'https://github.com/mizdra/css-modules-kit/blob/main/packages/
|
|
15
|
+
const meta: RuleMeta = {
|
|
16
|
+
url: 'https://github.com/mizdra/css-modules-kit/blob/main/packages/eslint-plugin/docs/rules/no-unused-class-names.md',
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
const ruleFunction: Rule = (_primaryOptions, _secondaryOptions, _context) => {
|