@css-modules-kit/stylelint-plugin 0.4.0 → 0.5.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/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/recommended.d.ts +1 -1
- package/dist/recommended.d.ts.map +1 -1
- package/dist/recommended.js +1 -2
- package/dist/recommended.js.map +1 -1
- package/dist/rules/no-missing-component-file.js +7 -13
- package/dist/rules/no-missing-component-file.js.map +1 -1
- package/dist/rules/no-unused-class-names.js +10 -16
- package/dist/rules/no-unused-class-names.js.map +1 -1
- package/dist/util.js +3 -9
- package/dist/util.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -1
- package/src/recommended.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const _default: import("stylelint").Plugin[];
|
|
2
|
-
export
|
|
1
|
+
declare const _default: import("stylelint", { with: { "resolution-mode": "require" } }).Plugin[];
|
|
2
|
+
export default _default;
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,wBAA4D"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
module.exports = [no_unused_class_names_js_1.noUnusedClassNames, no_missing_component_file_js_1.noMissingComponentFile];
|
|
1
|
+
import { noMissingComponentFile } from './rules/no-missing-component-file.js';
|
|
2
|
+
import { noUnusedClassNames } from './rules/no-unused-class-names.js';
|
|
3
|
+
export default [noUnusedClassNames, noMissingComponentFile];
|
|
5
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,eAAe,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAAC"}
|
package/dist/recommended.d.ts
CHANGED
|
@@ -1 +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,
|
|
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,eAAe,iBAAiB,CAAC"}
|
package/dist/recommended.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
const recommendedConfig = {
|
|
3
2
|
plugins: ['@css-modules-kit/stylelint-plugin'],
|
|
4
3
|
languageOptions: {
|
|
@@ -39,5 +38,5 @@ const recommendedConfig = {
|
|
|
39
38
|
'css-modules-kit/no-missing-component-file': true,
|
|
40
39
|
},
|
|
41
40
|
};
|
|
42
|
-
|
|
41
|
+
export default recommendedConfig;
|
|
43
42
|
//# sourceMappingURL=recommended.js.map
|
package/dist/recommended.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../src/recommended.ts"],"names":[],"mappings":"
|
|
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,qEAAqE;aAChF;SACF;KACF;IACD,KAAK,EAAE;QACL,uCAAuC,EAAE,IAAI;QAC7C,2CAA2C,EAAE,IAAI;KAClD;CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.noMissingComponentFile = void 0;
|
|
7
|
-
const core_1 = require("@css-modules-kit/core");
|
|
8
|
-
const stylelint_1 = __importDefault(require("stylelint"));
|
|
9
|
-
const util_js_1 = require("../util.js");
|
|
10
|
-
const { createPlugin, utils } = stylelint_1.default;
|
|
1
|
+
import { findComponentFile, isCSSModuleFile } from '@css-modules-kit/core';
|
|
2
|
+
import stylelint from 'stylelint';
|
|
3
|
+
import { readFile } from '../util.js';
|
|
4
|
+
const { createPlugin, utils } = stylelint;
|
|
11
5
|
const ruleName = 'css-modules-kit/no-missing-component-file';
|
|
12
6
|
const messages = utils.ruleMessages(ruleName, {
|
|
13
7
|
disallow: () => `The corresponding component file is not found.`,
|
|
@@ -18,9 +12,9 @@ const meta = {
|
|
|
18
12
|
const ruleFunction = (_primaryOptions, _secondaryOptions, _context) => {
|
|
19
13
|
return async (root, result) => {
|
|
20
14
|
const fileName = root.source?.input.file;
|
|
21
|
-
if (fileName === undefined || !
|
|
15
|
+
if (fileName === undefined || !isCSSModuleFile(fileName))
|
|
22
16
|
return;
|
|
23
|
-
const componentFile = await
|
|
17
|
+
const componentFile = await findComponentFile(fileName, readFile);
|
|
24
18
|
if (componentFile === undefined) {
|
|
25
19
|
utils.report({
|
|
26
20
|
result,
|
|
@@ -36,5 +30,5 @@ const ruleFunction = (_primaryOptions, _secondaryOptions, _context) => {
|
|
|
36
30
|
ruleFunction.ruleName = ruleName;
|
|
37
31
|
ruleFunction.messages = messages;
|
|
38
32
|
ruleFunction.meta = meta;
|
|
39
|
-
|
|
33
|
+
export const noMissingComponentFile = createPlugin(ruleName, ruleFunction);
|
|
40
34
|
//# sourceMappingURL=no-missing-component-file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-missing-component-file.js","sourceRoot":"","sources":["../../src/rules/no-missing-component-file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-missing-component-file.js","sourceRoot":"","sources":["../../src/rules/no-missing-component-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE3E,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,SAAS,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,eAAe,CAAC,QAAQ,CAAC;YAAE,OAAO;QAEjE,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,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;AAEzB,MAAM,CAAC,MAAM,sBAAsB,GAAG,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC"}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.noUnusedClassNames = void 0;
|
|
7
|
-
const core_1 = require("@css-modules-kit/core");
|
|
8
|
-
const stylelint_1 = __importDefault(require("stylelint"));
|
|
9
|
-
const util_js_1 = require("../util.js");
|
|
10
|
-
const { createPlugin, utils } = stylelint_1.default;
|
|
1
|
+
import { basename, findComponentFile, findUsedTokenNames, isCSSModuleFile, parseRule } from '@css-modules-kit/core';
|
|
2
|
+
import stylelint from 'stylelint';
|
|
3
|
+
import { readFile } from '../util.js';
|
|
4
|
+
const { createPlugin, utils } = stylelint;
|
|
11
5
|
const ruleName = 'css-modules-kit/no-unused-class-names';
|
|
12
6
|
const messages = utils.ruleMessages(ruleName, {
|
|
13
|
-
disallow: (className, componentFileName) => `"${className}" is defined but never used in "${
|
|
7
|
+
disallow: (className, componentFileName) => `"${className}" is defined but never used in "${basename(componentFileName)}"`,
|
|
14
8
|
});
|
|
15
9
|
const meta = {
|
|
16
10
|
url: 'https://github.com/mizdra/css-modules-kit/blob/main/packages/eslint-plugin/docs/rules/no-unused-class-names.md',
|
|
@@ -18,17 +12,17 @@ const meta = {
|
|
|
18
12
|
const ruleFunction = (_primaryOptions, _secondaryOptions, _context) => {
|
|
19
13
|
return async (root, result) => {
|
|
20
14
|
const fileName = root.source?.input.file;
|
|
21
|
-
if (fileName === undefined || !
|
|
15
|
+
if (fileName === undefined || !isCSSModuleFile(fileName))
|
|
22
16
|
return;
|
|
23
|
-
const componentFile = await
|
|
17
|
+
const componentFile = await findComponentFile(fileName, readFile);
|
|
24
18
|
// If the corresponding component file is not found, it is treated as a CSS Module file shared by the entire project.
|
|
25
19
|
// It is difficult to determine where class names in a shared CSS Module file are used. Therefore, it is
|
|
26
20
|
// assumed that all class names are used.
|
|
27
21
|
if (componentFile === undefined)
|
|
28
22
|
return;
|
|
29
|
-
const usedTokenNames =
|
|
23
|
+
const usedTokenNames = findUsedTokenNames(componentFile.text);
|
|
30
24
|
root.walkRules((rule) => {
|
|
31
|
-
const { classSelectors } =
|
|
25
|
+
const { classSelectors } = parseRule(rule);
|
|
32
26
|
for (const classSelector of classSelectors) {
|
|
33
27
|
if (!usedTokenNames.has(classSelector.name)) {
|
|
34
28
|
utils.report({
|
|
@@ -48,5 +42,5 @@ const ruleFunction = (_primaryOptions, _secondaryOptions, _context) => {
|
|
|
48
42
|
ruleFunction.ruleName = ruleName;
|
|
49
43
|
ruleFunction.messages = messages;
|
|
50
44
|
ruleFunction.meta = meta;
|
|
51
|
-
|
|
45
|
+
export const noUnusedClassNames = createPlugin(ruleName, ruleFunction);
|
|
52
46
|
//# sourceMappingURL=no-unused-class-names.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-unused-class-names.js","sourceRoot":"","sources":["../../src/rules/no-unused-class-names.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-unused-class-names.js","sourceRoot":"","sources":["../../src/rules/no-unused-class-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEpH,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,SAAS,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,QAAQ,CAAC,iBAAiB,CAAC,GAAG;CACjF,CAAC,CAAC;AAEH,MAAM,IAAI,GAAa;IACrB,GAAG,EAAE,gHAAgH;CACtH,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,IAA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@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.readFile = readFile;
|
|
7
|
-
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
8
|
-
async function readFile(path) {
|
|
9
|
-
return promises_1.default.readFile(path, 'utf-8');
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
export async function readFile(path) {
|
|
3
|
+
return fs.readFile(path, 'utf-8');
|
|
10
4
|
}
|
|
11
5
|
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY;IACzC,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACpC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@css-modules-kit/stylelint-plugin",
|
|
3
3
|
"description": "A stylelint plugin for CSS Modules",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"type": "
|
|
4
|
+
"version": "0.5.0",
|
|
5
|
+
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dist"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@css-modules-kit/core": "^0.
|
|
49
|
+
"@css-modules-kit/core": "^0.8.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"stylelint": "^16.0.0"
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { noMissingComponentFile } from './rules/no-missing-component-file.js';
|
|
2
2
|
import { noUnusedClassNames } from './rules/no-unused-class-names.js';
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export default [noUnusedClassNames, noMissingComponentFile];
|
package/src/recommended.ts
CHANGED