@drivenets/eslint-plugin-design-system 0.0.2 → 0.0.3
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 +6 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/create-plugin.cjs +16 -0
- package/dist/create-plugin.d.cts +12 -0
- package/dist/create-plugin.d.cts.map +1 -0
- package/dist/create-plugin.d.ts +12 -0
- package/dist/create-plugin.d.ts.map +1 -0
- package/dist/create-plugin.js +15 -0
- package/dist/create-plugin.js.map +1 -0
- package/dist/index.cjs +20 -73
- package/dist/index.d.cts +1 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -27
- package/dist/index.js.map +1 -1
- package/dist/selectors.cjs +18 -0
- package/dist/selectors.js +17 -0
- package/dist/selectors.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let eslint_no_restricted_syntax = require("eslint-no-restricted/syntax");
|
|
3
|
+
eslint_no_restricted_syntax = require_rolldown_runtime.__toESM(eslint_no_restricted_syntax);
|
|
4
|
+
|
|
5
|
+
//#region src/create-plugin.ts
|
|
6
|
+
/**
|
|
7
|
+
* Typed wrapper around `createNoRestrictedSyntax`.
|
|
8
|
+
*
|
|
9
|
+
* See: https://github.com/bradzacher/eslint-no-restricted/issues/13
|
|
10
|
+
*/
|
|
11
|
+
function createPlugin(name, ...rules) {
|
|
12
|
+
return (0, eslint_no_restricted_syntax.default)(name, ...rules);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.createPlugin = createPlugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RuleDefinition } from "@eslint/core";
|
|
2
|
+
import create from "eslint-no-restricted/syntax";
|
|
3
|
+
|
|
4
|
+
//#region src/create-plugin.d.ts
|
|
5
|
+
|
|
6
|
+
type BasePlugin = ReturnType<typeof create>;
|
|
7
|
+
type Plugin<TRules extends string> = Omit<BasePlugin, 'rules'> & {
|
|
8
|
+
rules: Record<TRules, RuleDefinition>;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Plugin };
|
|
12
|
+
//# sourceMappingURL=create-plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-plugin.d.cts","names":[],"sources":["../src/create-plugin.ts"],"sourcesContent":[],"mappings":";;;;;KAQK,UAAA,GAAa,UAE+B,CAAA,OAFb,MAEa,CAAA;AAAL,KAAhC,MAAgC,CAAA,eAAA,MAAA,CAAA,GAAA,IAAA,CAAK,UAAL,EAAA,OAAA,CAAA,GAAA;EAC7B,KAAA,EAAP,MAAO,CAAA,MAAA,EAAQ,cAAR,CAAA;CAAQ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import createNoRestrictedSyntax from "eslint-no-restricted/syntax";
|
|
2
|
+
import { RuleDefinition } from "@eslint/core";
|
|
3
|
+
|
|
4
|
+
//#region src/create-plugin.d.ts
|
|
5
|
+
|
|
6
|
+
type BasePlugin = ReturnType<typeof createNoRestrictedSyntax>;
|
|
7
|
+
type Plugin<TRules extends string> = Omit<BasePlugin, 'rules'> & {
|
|
8
|
+
rules: Record<TRules, RuleDefinition>;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Plugin };
|
|
12
|
+
//# sourceMappingURL=create-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-plugin.d.ts","names":[],"sources":["../src/create-plugin.ts"],"sourcesContent":[],"mappings":";;;;;KAQK,UAAA,GAAa,UAE+B,CAAA,OAFb,wBAEa,CAAA;AAAL,KAAhC,MAAgC,CAAA,eAAA,MAAA,CAAA,GAAA,IAAA,CAAK,UAAL,EAAA,OAAA,CAAA,GAAA;EAC7B,KAAA,EAAP,MAAO,CAAA,MAAA,EAAQ,cAAR,CAAA;CAAQ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import createNoRestrictedSyntax from "eslint-no-restricted/syntax";
|
|
2
|
+
|
|
3
|
+
//#region src/create-plugin.ts
|
|
4
|
+
/**
|
|
5
|
+
* Typed wrapper around `createNoRestrictedSyntax`.
|
|
6
|
+
*
|
|
7
|
+
* See: https://github.com/bradzacher/eslint-no-restricted/issues/13
|
|
8
|
+
*/
|
|
9
|
+
function createPlugin(name, ...rules) {
|
|
10
|
+
return createNoRestrictedSyntax(name, ...rules);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { createPlugin };
|
|
15
|
+
//# sourceMappingURL=create-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-plugin.js","names":[],"sources":["../src/create-plugin.ts"],"sourcesContent":["import type { RuleDefinition } from '@eslint/core';\nimport type create from 'eslint-no-restricted/syntax';\nimport createNoRestrictedSyntax from 'eslint-no-restricted/syntax';\n\ntype RuleConfig<TName extends string> = Omit<create.RuleConfig, 'name'> & {\n\tname: TName;\n};\n\ntype BasePlugin = ReturnType<typeof createNoRestrictedSyntax>;\n\nexport type Plugin<TRules extends string> = Omit<BasePlugin, 'rules'> & {\n\trules: Record<TRules, RuleDefinition>;\n};\n\n/**\n * Typed wrapper around `createNoRestrictedSyntax`.\n *\n * See: https://github.com/bradzacher/eslint-no-restricted/issues/13\n */\nexport function createPlugin<TRules extends string>(\n\tname: string,\n\t...rules: Array<RuleConfig<TRules>>\n): Plugin<TRules> {\n\treturn createNoRestrictedSyntax(name, ...rules) as Plugin<TRules>;\n}\n"],"mappings":";;;;;;;;AAmBA,SAAgB,aACf,MACA,GAAG,OACc;AACjB,QAAO,yBAAyB,MAAM,GAAG,MAAM"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,123 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
1
|
+
const require_selectors = require('./selectors.cjs');
|
|
2
|
+
const require_create_plugin = require('./create-plugin.cjs');
|
|
26
3
|
|
|
27
|
-
//#endregion
|
|
28
|
-
let eslint_no_restricted_syntax = require("eslint-no-restricted/syntax");
|
|
29
|
-
eslint_no_restricted_syntax = __toESM(eslint_no_restricted_syntax);
|
|
30
|
-
|
|
31
|
-
//#region src/selectors.ts
|
|
32
|
-
function JSXElement(name, attributes = {}) {
|
|
33
|
-
let selector = `JSXOpeningElement[name.name='${name}']`;
|
|
34
|
-
Object.entries(attributes).forEach(([attrName, attrValue]) => {
|
|
35
|
-
selector += `:has( > ${JSXAttribute(attrName, attrValue)} )`;
|
|
36
|
-
});
|
|
37
|
-
return selector;
|
|
38
|
-
}
|
|
39
|
-
function JSXAttribute(name, value) {
|
|
40
|
-
let selector = `JSXAttribute[name.name='${name}']`;
|
|
41
|
-
if (typeof value !== "undefined") selector += `:matches([value.expression.value='${value}'], [value.value='${value}'])`;
|
|
42
|
-
return selector;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/create-plugin.ts
|
|
47
|
-
/**
|
|
48
|
-
* Typed wrapper around `createNoRestrictedSyntax`.
|
|
49
|
-
*
|
|
50
|
-
* See: https://github.com/bradzacher/eslint-no-restricted/issues/13
|
|
51
|
-
*/
|
|
52
|
-
function createPlugin(name, ...rules) {
|
|
53
|
-
return (0, eslint_no_restricted_syntax.default)(name, ...rules);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
//#endregion
|
|
57
4
|
//#region src/index.ts
|
|
58
|
-
const eslintPlugin = createPlugin("drivenets-design-system", {
|
|
5
|
+
const eslintPlugin = require_create_plugin.createPlugin("drivenets-design-system", {
|
|
59
6
|
name: "no-deprecated-ds-button-legacy-design",
|
|
60
|
-
selector: [JSXElement("DsButton", { design: "legacy" }), `${JSXElement("DsButton")}:not(:has( > ${JSXAttribute("design")} ))`],
|
|
7
|
+
selector: [require_selectors.JSXElement("DsButton", { design: "legacy" }), `${require_selectors.JSXElement("DsButton")}:not(:has( > ${require_selectors.JSXAttribute("design")} ))`],
|
|
61
8
|
message: `Using the 'legacy' design for DsButton is deprecated. Use 'v1.2' instead.`
|
|
62
9
|
}, {
|
|
63
10
|
name: "no-deprecated-ds-dialog",
|
|
64
|
-
selector: JSXElement("DsDialog"),
|
|
11
|
+
selector: require_selectors.JSXElement("DsDialog"),
|
|
65
12
|
message: `DsDialog is deprecated. Use DsModal or DsConfirmation instead.`
|
|
66
13
|
}, {
|
|
67
14
|
name: "no-deprecated-ds-system-status",
|
|
68
|
-
selector: JSXElement("DsSystemStatus"),
|
|
15
|
+
selector: require_selectors.JSXElement("DsSystemStatus"),
|
|
69
16
|
message: `DsSystemStatus is deprecated. Use DsStatusBadge instead.`
|
|
70
17
|
}, {
|
|
71
18
|
name: "no-deprecated-ds-dropdown-menu-legacy",
|
|
72
|
-
selector: JSXElement("DsDropdownMenuLegacy"),
|
|
19
|
+
selector: require_selectors.JSXElement("DsDropdownMenuLegacy"),
|
|
73
20
|
message: `DsDropdownMenuLegacy is deprecated. Use DsDropdownMenu instead.`
|
|
74
21
|
}, {
|
|
75
22
|
name: "no-deprecated-ds-radio-group-legacy",
|
|
76
|
-
selector: JSXElement("DsRadioGroupLegacy"),
|
|
23
|
+
selector: require_selectors.JSXElement("DsRadioGroupLegacy"),
|
|
77
24
|
message: `DsRadioGroupLegacy is deprecated. Use DsRadioGroup instead.`
|
|
78
25
|
}, {
|
|
79
26
|
name: "no-native-button",
|
|
80
27
|
selector: [
|
|
81
|
-
JSXElement("button"),
|
|
82
|
-
JSXElement("input", { type: "button" }),
|
|
83
|
-
JSXElement("input", { type: "submit" })
|
|
28
|
+
require_selectors.JSXElement("button"),
|
|
29
|
+
require_selectors.JSXElement("input", { type: "button" }),
|
|
30
|
+
require_selectors.JSXElement("input", { type: "submit" })
|
|
84
31
|
],
|
|
85
32
|
message: `Using a native button is not allowed. Use DsButton instead.`
|
|
86
33
|
}, {
|
|
87
34
|
name: "no-native-select",
|
|
88
|
-
selector: JSXElement("select"),
|
|
35
|
+
selector: require_selectors.JSXElement("select"),
|
|
89
36
|
message: `Using a native select is not allowed. Use DsSelect or DsFormControl.Select instead.`
|
|
90
37
|
}, {
|
|
91
38
|
name: "no-native-checkbox",
|
|
92
|
-
selector: JSXElement("input", { type: "checkbox" }),
|
|
39
|
+
selector: require_selectors.JSXElement("input", { type: "checkbox" }),
|
|
93
40
|
message: `Using a native checkbox is not allowed. Use DsCheckbox instead.`
|
|
94
41
|
}, {
|
|
95
42
|
name: "no-native-radio",
|
|
96
|
-
selector: JSXElement("input", { type: "radio" }),
|
|
43
|
+
selector: require_selectors.JSXElement("input", { type: "radio" }),
|
|
97
44
|
message: `Using a native radio input is not allowed. Use DsRadioGroup instead.`
|
|
98
45
|
}, {
|
|
99
46
|
name: "no-native-number-input",
|
|
100
|
-
selector: JSXElement("input", { type: "number" }),
|
|
47
|
+
selector: require_selectors.JSXElement("input", { type: "number" }),
|
|
101
48
|
message: `Using a native number input is not allowed. Use DsNumberInput or DsFormControl.NumberInput instead.`
|
|
102
49
|
}, {
|
|
103
50
|
name: "no-native-text-input",
|
|
104
|
-
selector: [JSXElement("input", { type: "text" }), `${JSXElement("input")}:not(:has( > ${JSXAttribute("type")} ))`],
|
|
51
|
+
selector: [require_selectors.JSXElement("input", { type: "text" }), `${require_selectors.JSXElement("input")}:not(:has( > ${require_selectors.JSXAttribute("type")} ))`],
|
|
105
52
|
message: `Using a native text input is not allowed. Use DsTextInput or DsFormControl.TextInput instead.`
|
|
106
53
|
}, {
|
|
107
54
|
name: "no-native-password-input",
|
|
108
|
-
selector: JSXElement("input", { type: "password" }),
|
|
55
|
+
selector: require_selectors.JSXElement("input", { type: "password" }),
|
|
109
56
|
message: `Using a native password input is not allowed. Use DsPasswordInput or DsFormControl.PasswordInput instead.`
|
|
110
57
|
}, {
|
|
111
58
|
name: "no-native-file-input",
|
|
112
|
-
selector: JSXElement("input", { type: "file" }),
|
|
59
|
+
selector: require_selectors.JSXElement("input", { type: "file" }),
|
|
113
60
|
message: `Using a native file input is not allowed. Use DsFileUpload instead.`
|
|
114
61
|
}, {
|
|
115
62
|
name: "no-native-textarea",
|
|
116
|
-
selector: JSXElement("textarea"),
|
|
63
|
+
selector: require_selectors.JSXElement("textarea"),
|
|
117
64
|
message: `Using a native textarea is not allowed. Use DsTextarea or DsFormControl.Textarea instead.`
|
|
118
65
|
}, {
|
|
119
66
|
name: "no-native-table",
|
|
120
|
-
selector: JSXElement("table"),
|
|
67
|
+
selector: require_selectors.JSXElement("table"),
|
|
121
68
|
message: `Using a native table is not allowed. Use DsTable instead.`
|
|
122
69
|
}, {
|
|
123
70
|
name: "no-mui",
|
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import create from "eslint-no-restricted/syntax";
|
|
1
|
+
import { Plugin } from "./create-plugin.cjs";
|
|
3
2
|
|
|
4
|
-
//#region src/create-plugin.d.ts
|
|
5
|
-
|
|
6
|
-
type BasePlugin = ReturnType<typeof create>;
|
|
7
|
-
type Plugin<TRules extends string> = Omit<BasePlugin, 'rules'> & {
|
|
8
|
-
rules: Record<TRules, RuleDefinition>;
|
|
9
|
-
};
|
|
10
|
-
//#endregion
|
|
11
3
|
//#region src/index.d.ts
|
|
12
4
|
declare const eslintPlugin: Plugin<"no-deprecated-ds-button-legacy-design" | "no-deprecated-ds-dialog" | "no-deprecated-ds-system-status" | "no-deprecated-ds-dropdown-menu-legacy" | "no-deprecated-ds-radio-group-legacy" | "no-native-button" | "no-native-select" | "no-native-checkbox" | "no-native-radio" | "no-native-number-input" | "no-native-text-input" | "no-native-password-input" | "no-native-file-input" | "no-native-textarea" | "no-native-table" | "no-mui">;
|
|
13
5
|
export = eslintPlugin;
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;cAGM,cA2GL"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { RuleDefinition } from "@eslint/core";
|
|
1
|
+
import { Plugin } from "./create-plugin.js";
|
|
3
2
|
|
|
4
|
-
//#region src/create-plugin.d.ts
|
|
5
|
-
|
|
6
|
-
type BasePlugin = ReturnType<typeof createNoRestrictedSyntax>;
|
|
7
|
-
type Plugin<TRules extends string> = Omit<BasePlugin, 'rules'> & {
|
|
8
|
-
rules: Record<TRules, RuleDefinition>;
|
|
9
|
-
};
|
|
10
|
-
//#endregion
|
|
11
3
|
//#region src/index.d.ts
|
|
12
4
|
declare const eslintPlugin: Plugin<"no-deprecated-ds-button-legacy-design" | "no-deprecated-ds-dialog" | "no-deprecated-ds-system-status" | "no-deprecated-ds-dropdown-menu-legacy" | "no-deprecated-ds-radio-group-legacy" | "no-native-button" | "no-native-select" | "no-native-checkbox" | "no-native-radio" | "no-native-number-input" | "no-native-text-input" | "no-native-password-input" | "no-native-file-input" | "no-native-textarea" | "no-native-table" | "no-mui">;
|
|
13
5
|
//#endregion
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;cAGM,cA2GL"}
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { JSXAttribute, JSXElement } from "./selectors.js";
|
|
2
|
+
import { createPlugin } from "./create-plugin.js";
|
|
2
3
|
|
|
3
|
-
//#region src/selectors.ts
|
|
4
|
-
function JSXElement(name, attributes = {}) {
|
|
5
|
-
let selector = `JSXOpeningElement[name.name='${name}']`;
|
|
6
|
-
Object.entries(attributes).forEach(([attrName, attrValue]) => {
|
|
7
|
-
selector += `:has( > ${JSXAttribute(attrName, attrValue)} )`;
|
|
8
|
-
});
|
|
9
|
-
return selector;
|
|
10
|
-
}
|
|
11
|
-
function JSXAttribute(name, value) {
|
|
12
|
-
let selector = `JSXAttribute[name.name='${name}']`;
|
|
13
|
-
if (typeof value !== "undefined") selector += `:matches([value.expression.value='${value}'], [value.value='${value}'])`;
|
|
14
|
-
return selector;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/create-plugin.ts
|
|
19
|
-
/**
|
|
20
|
-
* Typed wrapper around `createNoRestrictedSyntax`.
|
|
21
|
-
*
|
|
22
|
-
* See: https://github.com/bradzacher/eslint-no-restricted/issues/13
|
|
23
|
-
*/
|
|
24
|
-
function createPlugin(name, ...rules) {
|
|
25
|
-
return createNoRestrictedSyntax(name, ...rules);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
4
|
//#region src/index.ts
|
|
30
5
|
const eslintPlugin = createPlugin("drivenets-design-system", {
|
|
31
6
|
name: "no-deprecated-ds-button-legacy-design",
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { JSXAttribute, JSXElement } from './selectors';\nimport { createPlugin } from './create-plugin';\n\nconst eslintPlugin = createPlugin(\n\t'drivenets-design-system',\n\t{\n\t\tname: 'no-deprecated-ds-button-legacy-design',\n\t\tselector: [\n\t\t\tJSXElement('DsButton', { design: 'legacy' }),\n\t\t\t`${JSXElement('DsButton')}:not(:has( > ${JSXAttribute('design')} ))`,\n\t\t],\n\t\tmessage: `Using the 'legacy' design for DsButton is deprecated. Use 'v1.2' instead.`,\n\t},\n\n\t{\n\t\tname: 'no-deprecated-ds-dialog',\n\t\tselector: JSXElement('DsDialog'),\n\t\tmessage: `DsDialog is deprecated. Use DsModal or DsConfirmation instead.`,\n\t},\n\n\t{\n\t\tname: 'no-deprecated-ds-system-status',\n\t\tselector: JSXElement('DsSystemStatus'),\n\t\tmessage: `DsSystemStatus is deprecated. Use DsStatusBadge instead.`,\n\t},\n\n\t{\n\t\tname: 'no-deprecated-ds-dropdown-menu-legacy',\n\t\tselector: JSXElement('DsDropdownMenuLegacy'),\n\t\tmessage: `DsDropdownMenuLegacy is deprecated. Use DsDropdownMenu instead.`,\n\t},\n\n\t{\n\t\tname: 'no-deprecated-ds-radio-group-legacy',\n\t\tselector: JSXElement('DsRadioGroupLegacy'),\n\t\tmessage: `DsRadioGroupLegacy is deprecated. Use DsRadioGroup instead.`,\n\t},\n\n\t{\n\t\tname: 'no-native-button',\n\t\tselector: [\n\t\t\tJSXElement('button'),\n\t\t\tJSXElement('input', { type: 'button' }),\n\t\t\tJSXElement('input', { type: 'submit' }),\n\t\t],\n\t\tmessage: `Using a native button is not allowed. Use DsButton instead.`,\n\t},\n\n\t{\n\t\tname: 'no-native-select',\n\t\tselector: JSXElement('select'),\n\t\tmessage: `Using a native select is not allowed. Use DsSelect or DsFormControl.Select instead.`,\n\t},\n\n\t{\n\t\tname: 'no-native-checkbox',\n\t\tselector: JSXElement('input', { type: 'checkbox' }),\n\t\tmessage: `Using a native checkbox is not allowed. Use DsCheckbox instead.`,\n\t},\n\n\t{\n\t\tname: 'no-native-radio',\n\t\tselector: JSXElement('input', { type: 'radio' }),\n\t\tmessage: `Using a native radio input is not allowed. Use DsRadioGroup instead.`,\n\t},\n\n\t{\n\t\tname: 'no-native-number-input',\n\t\tselector: JSXElement('input', { type: 'number' }),\n\t\tmessage: `Using a native number input is not allowed. Use DsNumberInput or DsFormControl.NumberInput instead.`,\n\t},\n\n\t{\n\t\tname: 'no-native-text-input',\n\t\tselector: [\n\t\t\tJSXElement('input', { type: 'text' }),\n\t\t\t`${JSXElement('input')}:not(:has( > ${JSXAttribute('type')} ))`,\n\t\t],\n\t\tmessage: `Using a native text input is not allowed. Use DsTextInput or DsFormControl.TextInput instead.`,\n\t},\n\n\t{\n\t\tname: 'no-native-password-input',\n\t\tselector: JSXElement('input', { type: 'password' }),\n\t\tmessage: `Using a native password input is not allowed. Use DsPasswordInput or DsFormControl.PasswordInput instead.`,\n\t},\n\n\t{\n\t\tname: 'no-native-file-input',\n\t\tselector: JSXElement('input', { type: 'file' }),\n\t\tmessage: `Using a native file input is not allowed. Use DsFileUpload instead.`,\n\t},\n\n\t{\n\t\tname: 'no-native-textarea',\n\t\tselector: JSXElement('textarea'),\n\t\tmessage: `Using a native textarea is not allowed. Use DsTextarea or DsFormControl.Textarea instead.`,\n\t},\n\n\t{\n\t\tname: 'no-native-table',\n\t\tselector: JSXElement('table'),\n\t\tmessage: `Using a native table is not allowed. Use DsTable instead.`,\n\t},\n\n\t{\n\t\tname: 'no-mui',\n\t\tselector: 'ImportDeclaration[source.value=/^@mui\\\\u002F/]',\n\t\tmessage: 'Using MUI components is not allowed. Use DriveNets Design System components instead.',\n\t},\n);\n\nexport default eslintPlugin;\n"],"mappings":";;;;AAGA,MAAM,eAAe,aACpB,2BACA;CACC,MAAM;CACN,UAAU,CACT,WAAW,YAAY,EAAE,QAAQ,UAAU,CAAC,EAC5C,GAAG,WAAW,WAAW,CAAC,eAAe,aAAa,SAAS,CAAC,KAChE;CACD,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU,WAAW,WAAW;CAChC,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU,WAAW,iBAAiB;CACtC,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU,WAAW,uBAAuB;CAC5C,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU,WAAW,qBAAqB;CAC1C,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU;EACT,WAAW,SAAS;EACpB,WAAW,SAAS,EAAE,MAAM,UAAU,CAAC;EACvC,WAAW,SAAS,EAAE,MAAM,UAAU,CAAC;EACvC;CACD,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU,WAAW,SAAS;CAC9B,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU,WAAW,SAAS,EAAE,MAAM,YAAY,CAAC;CACnD,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU,WAAW,SAAS,EAAE,MAAM,SAAS,CAAC;CAChD,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU,WAAW,SAAS,EAAE,MAAM,UAAU,CAAC;CACjD,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU,CACT,WAAW,SAAS,EAAE,MAAM,QAAQ,CAAC,EACrC,GAAG,WAAW,QAAQ,CAAC,eAAe,aAAa,OAAO,CAAC,KAC3D;CACD,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU,WAAW,SAAS,EAAE,MAAM,YAAY,CAAC;CACnD,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU,WAAW,SAAS,EAAE,MAAM,QAAQ,CAAC;CAC/C,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU,WAAW,WAAW;CAChC,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU,WAAW,QAAQ;CAC7B,SAAS;CACT,EAED;CACC,MAAM;CACN,UAAU;CACV,SAAS;CACT,CACD;AAED,kBAAe"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/selectors.ts
|
|
3
|
+
function JSXElement(name, attributes = {}) {
|
|
4
|
+
let selector = `JSXOpeningElement[name.name='${name}']`;
|
|
5
|
+
Object.entries(attributes).forEach(([attrName, attrValue]) => {
|
|
6
|
+
selector += `:has( > ${JSXAttribute(attrName, attrValue)} )`;
|
|
7
|
+
});
|
|
8
|
+
return selector;
|
|
9
|
+
}
|
|
10
|
+
function JSXAttribute(name, value) {
|
|
11
|
+
let selector = `JSXAttribute[name.name='${name}']`;
|
|
12
|
+
if (typeof value !== "undefined") selector += `:matches([value.expression.value='${value}'], [value.value='${value}'])`;
|
|
13
|
+
return selector;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.JSXAttribute = JSXAttribute;
|
|
18
|
+
exports.JSXElement = JSXElement;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/selectors.ts
|
|
2
|
+
function JSXElement(name, attributes = {}) {
|
|
3
|
+
let selector = `JSXOpeningElement[name.name='${name}']`;
|
|
4
|
+
Object.entries(attributes).forEach(([attrName, attrValue]) => {
|
|
5
|
+
selector += `:has( > ${JSXAttribute(attrName, attrValue)} )`;
|
|
6
|
+
});
|
|
7
|
+
return selector;
|
|
8
|
+
}
|
|
9
|
+
function JSXAttribute(name, value) {
|
|
10
|
+
let selector = `JSXAttribute[name.name='${name}']`;
|
|
11
|
+
if (typeof value !== "undefined") selector += `:matches([value.expression.value='${value}'], [value.value='${value}'])`;
|
|
12
|
+
return selector;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { JSXAttribute, JSXElement };
|
|
17
|
+
//# sourceMappingURL=selectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.js","names":[],"sources":["../src/selectors.ts"],"sourcesContent":["export function JSXElement(name: string, attributes: Record<string, string> = {}) {\n\tlet selector = `JSXOpeningElement[name.name='${name}']`;\n\n\tObject.entries(attributes).forEach(([attrName, attrValue]) => {\n\t\tselector += `:has( > ${JSXAttribute(attrName, attrValue)} )`;\n\t});\n\n\treturn selector;\n}\n\nexport function JSXAttribute(name: string, value?: string) {\n\tlet selector = `JSXAttribute[name.name='${name}']`;\n\n\tif (typeof value !== 'undefined') {\n\t\t// Match both expressions (prop={'value'}) and literal values (prop=\"value\").\n\t\tselector += `:matches([value.expression.value='${value}'], [value.value='${value}'])`;\n\t}\n\n\treturn selector;\n}\n"],"mappings":";AAAA,SAAgB,WAAW,MAAc,aAAqC,EAAE,EAAE;CACjF,IAAI,WAAW,gCAAgC,KAAK;AAEpD,QAAO,QAAQ,WAAW,CAAC,SAAS,CAAC,UAAU,eAAe;AAC7D,cAAY,WAAW,aAAa,UAAU,UAAU,CAAC;GACxD;AAEF,QAAO;;AAGR,SAAgB,aAAa,MAAc,OAAgB;CAC1D,IAAI,WAAW,2BAA2B,KAAK;AAE/C,KAAI,OAAO,UAAU,YAEpB,aAAY,qCAAqC,MAAM,oBAAoB,MAAM;AAGlF,QAAO"}
|