@stardeck-customer-apps/eslint-plugin 1.0.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.cjs +101 -0
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +73 -0
- package/package.json +59 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
configs: () => configs,
|
|
24
|
+
default: () => index_default,
|
|
25
|
+
rules: () => rules
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
29
|
+
// src/rules/no-template-literal-classname.ts
|
|
30
|
+
var rule = {
|
|
31
|
+
meta: {
|
|
32
|
+
type: "suggestion",
|
|
33
|
+
docs: {
|
|
34
|
+
description: "Disallow template literal interpolation in className, use cn() instead",
|
|
35
|
+
recommended: true
|
|
36
|
+
},
|
|
37
|
+
messages: {
|
|
38
|
+
noTemplateLiteral: "Avoid template literals with interpolation in className. Use cn() from '@/lib/utils' instead."
|
|
39
|
+
},
|
|
40
|
+
schema: []
|
|
41
|
+
},
|
|
42
|
+
create(context) {
|
|
43
|
+
return {
|
|
44
|
+
JSXAttribute(node) {
|
|
45
|
+
if (node.name.type !== "JSXIdentifier" || node.name.name !== "className") {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (!node.value || node.value.type !== "JSXExpressionContainer") {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const container = node.value;
|
|
52
|
+
const expression = container.expression;
|
|
53
|
+
if (expression.type === "TemplateLiteral") {
|
|
54
|
+
const templateLiteral = expression;
|
|
55
|
+
if (templateLiteral.expressions.length > 0) {
|
|
56
|
+
context.report({
|
|
57
|
+
node,
|
|
58
|
+
messageId: "noTemplateLiteral"
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var no_template_literal_classname_default = rule;
|
|
67
|
+
|
|
68
|
+
// src/rules/index.ts
|
|
69
|
+
var rules = {
|
|
70
|
+
"no-template-literal-classname": no_template_literal_classname_default
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// src/configs/recommended.ts
|
|
74
|
+
var pluginName = "@stardeck-customer-apps/eslint-plugin";
|
|
75
|
+
var recommended = {
|
|
76
|
+
plugins: {
|
|
77
|
+
[pluginName]: {
|
|
78
|
+
rules
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
rules: {
|
|
82
|
+
[`${pluginName}/no-template-literal-classname`]: "error"
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// src/configs/index.ts
|
|
87
|
+
var configs = {
|
|
88
|
+
recommended
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// src/index.ts
|
|
92
|
+
var plugin = {
|
|
93
|
+
rules,
|
|
94
|
+
configs
|
|
95
|
+
};
|
|
96
|
+
var index_default = plugin;
|
|
97
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
98
|
+
0 && (module.exports = {
|
|
99
|
+
configs,
|
|
100
|
+
rules
|
|
101
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as eslint from 'eslint';
|
|
2
|
+
|
|
3
|
+
declare const rules: {
|
|
4
|
+
"no-template-literal-classname": eslint.Rule.RuleModule;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
declare const configs: {
|
|
8
|
+
recommended: eslint.Linter.Config<eslint.Linter.RulesRecord>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
declare const plugin: {
|
|
12
|
+
rules: {
|
|
13
|
+
"no-template-literal-classname": eslint.Rule.RuleModule;
|
|
14
|
+
};
|
|
15
|
+
configs: {
|
|
16
|
+
recommended: eslint.Linter.Config<eslint.Linter.RulesRecord>;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { configs, plugin as default, rules };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as eslint from 'eslint';
|
|
2
|
+
|
|
3
|
+
declare const rules: {
|
|
4
|
+
"no-template-literal-classname": eslint.Rule.RuleModule;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
declare const configs: {
|
|
8
|
+
recommended: eslint.Linter.Config<eslint.Linter.RulesRecord>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
declare const plugin: {
|
|
12
|
+
rules: {
|
|
13
|
+
"no-template-literal-classname": eslint.Rule.RuleModule;
|
|
14
|
+
};
|
|
15
|
+
configs: {
|
|
16
|
+
recommended: eslint.Linter.Config<eslint.Linter.RulesRecord>;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { configs, plugin as default, rules };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// src/rules/no-template-literal-classname.ts
|
|
2
|
+
var rule = {
|
|
3
|
+
meta: {
|
|
4
|
+
type: "suggestion",
|
|
5
|
+
docs: {
|
|
6
|
+
description: "Disallow template literal interpolation in className, use cn() instead",
|
|
7
|
+
recommended: true
|
|
8
|
+
},
|
|
9
|
+
messages: {
|
|
10
|
+
noTemplateLiteral: "Avoid template literals with interpolation in className. Use cn() from '@/lib/utils' instead."
|
|
11
|
+
},
|
|
12
|
+
schema: []
|
|
13
|
+
},
|
|
14
|
+
create(context) {
|
|
15
|
+
return {
|
|
16
|
+
JSXAttribute(node) {
|
|
17
|
+
if (node.name.type !== "JSXIdentifier" || node.name.name !== "className") {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (!node.value || node.value.type !== "JSXExpressionContainer") {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const container = node.value;
|
|
24
|
+
const expression = container.expression;
|
|
25
|
+
if (expression.type === "TemplateLiteral") {
|
|
26
|
+
const templateLiteral = expression;
|
|
27
|
+
if (templateLiteral.expressions.length > 0) {
|
|
28
|
+
context.report({
|
|
29
|
+
node,
|
|
30
|
+
messageId: "noTemplateLiteral"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var no_template_literal_classname_default = rule;
|
|
39
|
+
|
|
40
|
+
// src/rules/index.ts
|
|
41
|
+
var rules = {
|
|
42
|
+
"no-template-literal-classname": no_template_literal_classname_default
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// src/configs/recommended.ts
|
|
46
|
+
var pluginName = "@stardeck-customer-apps/eslint-plugin";
|
|
47
|
+
var recommended = {
|
|
48
|
+
plugins: {
|
|
49
|
+
[pluginName]: {
|
|
50
|
+
rules
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
rules: {
|
|
54
|
+
[`${pluginName}/no-template-literal-classname`]: "error"
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// src/configs/index.ts
|
|
59
|
+
var configs = {
|
|
60
|
+
recommended
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/index.ts
|
|
64
|
+
var plugin = {
|
|
65
|
+
rules,
|
|
66
|
+
configs
|
|
67
|
+
};
|
|
68
|
+
var index_default = plugin;
|
|
69
|
+
export {
|
|
70
|
+
configs,
|
|
71
|
+
index_default as default,
|
|
72
|
+
rules
|
|
73
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stardeck-customer-apps/eslint-plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Custom ESLint rules for Stardeck customer apps",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"registry": "https://registry.npmjs.org/",
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"require": "./dist/index.cjs",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
26
|
+
"dev": "tsup src/index.ts --format esm,cjs --dts --watch",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"format": "prettier --write . && eslint . --fix",
|
|
29
|
+
"lint": "eslint src/",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:watch": "vitest --watch"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"stardeck",
|
|
35
|
+
"eslint",
|
|
36
|
+
"eslint-plugin",
|
|
37
|
+
"tailwind",
|
|
38
|
+
"classname"
|
|
39
|
+
],
|
|
40
|
+
"author": "Stardeck",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"eslint": "^9.0.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@eslint/js": "^9.31.0",
|
|
47
|
+
"@stardeck-customer-apps/tsconfig": "*",
|
|
48
|
+
"@types/eslint": "^9.6.1",
|
|
49
|
+
"@types/estree": "^1.0.7",
|
|
50
|
+
"@types/estree-jsx": "^1.0.5",
|
|
51
|
+
"@types/node": "^22.10.0",
|
|
52
|
+
"eslint": "^9.31.0",
|
|
53
|
+
"globals": "^16.3.0",
|
|
54
|
+
"tsup": "^8.0.0",
|
|
55
|
+
"typescript": "~5.8.3",
|
|
56
|
+
"typescript-eslint": "^8.38.0",
|
|
57
|
+
"vitest": "^3.2.4"
|
|
58
|
+
}
|
|
59
|
+
}
|