@superdispatch/eslint-plugin-ui 0.21.6 → 0.21.13

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/pkg/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- export declare const rules: {
2
- readonly 'no-color-literals': import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"suggestColor", [], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
3
- readonly 'no-restricted-modules': import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"restrict", [], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
4
- };
5
- export declare const configs: {
6
- readonly recommended: {
7
- readonly plugins: readonly ["@superdispatch/ui"];
8
- readonly rules: {
9
- readonly '@superdispatch/ui/no-color-literals': readonly ["error"];
10
- readonly '@superdispatch/ui/no-restricted-modules': readonly ["error"];
11
- };
12
- };
13
- };
1
+ export declare const rules: {
2
+ readonly 'no-color-literals': import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"suggestColor", [], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
3
+ readonly 'no-restricted-modules': import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"restrict", [], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
4
+ };
5
+ export declare const configs: {
6
+ readonly recommended: {
7
+ readonly plugins: readonly ["@superdispatch/ui"];
8
+ readonly rules: {
9
+ readonly '@superdispatch/ui/no-color-literals': readonly ["error"];
10
+ readonly '@superdispatch/ui/no-restricted-modules': readonly ["error"];
11
+ };
12
+ };
13
+ };
package/pkg/index.js CHANGED
@@ -1,18 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configs = exports.rules = void 0;
4
- const no_color_literals_1 = require("./rules/no-color-literals");
5
- const no_restricted_modules_1 = require("./rules/no-restricted-modules");
6
- exports.rules = {
7
- 'no-color-literals': no_color_literals_1.rule,
8
- 'no-restricted-modules': no_restricted_modules_1.rule,
9
- };
10
- exports.configs = {
11
- recommended: {
12
- plugins: ['@superdispatch/ui'],
13
- rules: {
14
- '@superdispatch/ui/no-color-literals': ['error'],
15
- '@superdispatch/ui/no-restricted-modules': ['error'],
16
- },
17
- },
18
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configs = exports.rules = void 0;
4
+ const no_color_literals_1 = require("./rules/no-color-literals");
5
+ const no_restricted_modules_1 = require("./rules/no-restricted-modules");
6
+ exports.rules = {
7
+ 'no-color-literals': no_color_literals_1.rule,
8
+ 'no-restricted-modules': no_restricted_modules_1.rule,
9
+ };
10
+ exports.configs = {
11
+ recommended: {
12
+ plugins: ['@superdispatch/ui'],
13
+ rules: {
14
+ '@superdispatch/ui/no-color-literals': ['error'],
15
+ '@superdispatch/ui/no-restricted-modules': ['error'],
16
+ },
17
+ },
18
+ };
@@ -1,6 +1,6 @@
1
- declare const messages: {
2
- readonly suggestColor: "Use `Color.{{name}}` from \"@superdispatch/ui\"";
3
- };
4
- export declare type MessageIds = keyof typeof messages;
5
- export declare const rule: import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"suggestColor", [], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
6
- export {};
1
+ declare const messages: {
2
+ readonly suggestColor: "Use `Color.{{name}}` from \"@superdispatch/ui\"";
3
+ };
4
+ export declare type MessageIds = keyof typeof messages;
5
+ export declare const rule: import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"suggestColor", [], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
6
+ export {};
@@ -1,82 +1,82 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rule = void 0;
4
- const ui_1 = require("@superdispatch/ui");
5
- const createRule_1 = require("../utils/createRule");
6
- //
7
- // Utils
8
- //
9
- function normalizeHex(hex) {
10
- hex = hex.toLowerCase();
11
- // #ffffff -> #fff
12
- if (new Set(hex).size === 2) {
13
- hex = hex.charAt(0) + hex.charAt(1).repeat(3);
14
- }
15
- return hex;
16
- }
17
- const COLOR_KEY_CACHE = new Map();
18
- function findColorName(color) {
19
- if (COLOR_KEY_CACHE.size === 0) {
20
- for (const [key, hex] of Object.entries(ui_1.Color)) {
21
- COLOR_KEY_CACHE.set(normalizeHex(hex), key);
22
- }
23
- }
24
- return COLOR_KEY_CACHE.get(color);
25
- }
26
- const HEX_COLOR_PATTERN = /(#\b([a-f0-9]{3}|[a-f0-9]{6})\b)/gim;
27
- function* listColorNames(text) {
28
- for (const [, hex] of text.matchAll(HEX_COLOR_PATTERN)) {
29
- if (hex) {
30
- const color = normalizeHex(hex);
31
- const name = findColorName(color);
32
- if (name)
33
- yield name;
34
- }
35
- }
36
- }
37
- //
38
- // Rule
39
- //
40
- const messages = {
41
- suggestColor: 'Use `Color.{{name}}` from "@superdispatch/ui"',
42
- };
43
- exports.rule = (0, createRule_1.createRule)({
44
- name: 'no-restricted-modules',
45
- defaultOptions: [],
46
- meta: {
47
- messages,
48
- type: 'problem',
49
- fixable: 'code',
50
- docs: {
51
- recommended: 'error',
52
- description: 'Disallows to use Material UI modules',
53
- },
54
- schema: [],
55
- },
56
- create(context) {
57
- return {
58
- Literal(node) {
59
- if (typeof node.value == 'string') {
60
- for (const name of listColorNames(node.value)) {
61
- context.report({
62
- node,
63
- data: { name },
64
- messageId: 'suggestColor',
65
- });
66
- }
67
- }
68
- },
69
- TemplateLiteral(node) {
70
- for (const quasi of node.quasis) {
71
- for (const name of listColorNames(quasi.value.raw)) {
72
- context.report({
73
- node,
74
- data: { name },
75
- messageId: 'suggestColor',
76
- });
77
- }
78
- }
79
- },
80
- };
81
- },
82
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rule = void 0;
4
+ const ui_1 = require("@superdispatch/ui");
5
+ const createRule_1 = require("../utils/createRule");
6
+ //
7
+ // Utils
8
+ //
9
+ function normalizeHex(hex) {
10
+ hex = hex.toLowerCase();
11
+ // #ffffff -> #fff
12
+ if (new Set(hex).size === 2) {
13
+ hex = hex.charAt(0) + hex.charAt(1).repeat(3);
14
+ }
15
+ return hex;
16
+ }
17
+ const COLOR_KEY_CACHE = new Map();
18
+ function findColorName(color) {
19
+ if (COLOR_KEY_CACHE.size === 0) {
20
+ for (const [key, hex] of Object.entries(ui_1.Color)) {
21
+ COLOR_KEY_CACHE.set(normalizeHex(hex), key);
22
+ }
23
+ }
24
+ return COLOR_KEY_CACHE.get(color);
25
+ }
26
+ const HEX_COLOR_PATTERN = /(#\b([a-f0-9]{3}|[a-f0-9]{6})\b)/gim;
27
+ function* listColorNames(text) {
28
+ for (const [, hex] of text.matchAll(HEX_COLOR_PATTERN)) {
29
+ if (hex) {
30
+ const color = normalizeHex(hex);
31
+ const name = findColorName(color);
32
+ if (name)
33
+ yield name;
34
+ }
35
+ }
36
+ }
37
+ //
38
+ // Rule
39
+ //
40
+ const messages = {
41
+ suggestColor: 'Use `Color.{{name}}` from "@superdispatch/ui"',
42
+ };
43
+ exports.rule = (0, createRule_1.createRule)({
44
+ name: 'no-restricted-modules',
45
+ defaultOptions: [],
46
+ meta: {
47
+ messages,
48
+ type: 'problem',
49
+ fixable: 'code',
50
+ docs: {
51
+ recommended: 'error',
52
+ description: 'Disallows to use Material UI modules',
53
+ },
54
+ schema: [],
55
+ },
56
+ create(context) {
57
+ return {
58
+ Literal(node) {
59
+ if (typeof node.value == 'string') {
60
+ for (const name of listColorNames(node.value)) {
61
+ context.report({
62
+ node,
63
+ data: { name },
64
+ messageId: 'suggestColor',
65
+ });
66
+ }
67
+ }
68
+ },
69
+ TemplateLiteral(node) {
70
+ for (const quasi of node.quasis) {
71
+ for (const name of listColorNames(quasi.value.raw)) {
72
+ context.report({
73
+ node,
74
+ data: { name },
75
+ messageId: 'suggestColor',
76
+ });
77
+ }
78
+ }
79
+ },
80
+ };
81
+ },
82
+ });
@@ -1,6 +1,6 @@
1
- declare const messages: {
2
- readonly restrict: "Usage of `{{restrictedName}}` from `{{restrictedModule}}` is restricted, use `{{suggestedName}}` from the `{{suggestedModule}}`";
3
- };
4
- export declare type MessageIds = keyof typeof messages;
5
- export declare const rule: import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"restrict", [], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
6
- export {};
1
+ declare const messages: {
2
+ readonly restrict: "Usage of `{{restrictedName}}` from `{{restrictedModule}}` is restricted, use `{{suggestedName}}` from the `{{suggestedModule}}`";
3
+ };
4
+ export declare type MessageIds = keyof typeof messages;
5
+ export declare const rule: import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"restrict", [], import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>;
6
+ export {};
@@ -1,75 +1,75 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rule = void 0;
4
- const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
5
- const createRule_1 = require("../utils/createRule");
6
- const messages = {
7
- restrict: 'Usage of `{{restrictedName}}` from `{{restrictedModule}}` is restricted, use `{{suggestedName}}` from the `{{suggestedModule}}`',
8
- };
9
- const RESTRICTIONS = {
10
- '@material-ui/lab': {
11
- Alert: ['Alert', '@superdispatch/ui-lab'],
12
- },
13
- '@material-ui/core': {
14
- Grid: ['Columns', '@superdispatch/ui-lab'],
15
- Box: ['Box', '@superdispatch/ui-lab'],
16
- Button: ['Button', '@superdispatch/ui-lab'],
17
- Snackbar: ['Snackbar', '@superdispatch/ui'],
18
- SnackbarContent: ['SnackbarContent', '@superdispatch/ui'],
19
- },
20
- '@superdispatch/ui': {
21
- Button: ['Button', '@superdispatch/ui-lab'],
22
- GridStack: ['Stack', '@superdispatch/ui'],
23
- InlineGrid: ['Inline', '@superdispatch/ui'],
24
- DescriptionList: ['Stack', '@superdispatch/ui-lab'],
25
- DescriptionListItem: ['DescriptionItem', '@superdispatch/ui-lab'],
26
- },
27
- };
28
- exports.rule = (0, createRule_1.createRule)({
29
- name: 'no-restricted-modules',
30
- defaultOptions: [],
31
- meta: {
32
- messages,
33
- type: 'problem',
34
- fixable: 'code',
35
- docs: {
36
- recommended: 'error',
37
- description: 'Disallows to use Material UI modules',
38
- },
39
- schema: [],
40
- },
41
- create(context) {
42
- return {
43
- ImportDeclaration(node) {
44
- const { value: restrictedModule } = node.source;
45
- if (typeof restrictedModule != 'string')
46
- return;
47
- const packageRestrictions = RESTRICTIONS[restrictedModule];
48
- if (!packageRestrictions)
49
- return;
50
- for (const specifier of node.specifiers) {
51
- if (specifier.type === experimental_utils_1.AST_NODE_TYPES.ImportNamespaceSpecifier) {
52
- continue;
53
- }
54
- const restrictedName = specifier.type === experimental_utils_1.AST_NODE_TYPES.ImportDefaultSpecifier
55
- ? 'default'
56
- : specifier.imported.name;
57
- const moduleRestrictions = packageRestrictions[restrictedName];
58
- if (!moduleRestrictions)
59
- continue;
60
- const [suggestedName, suggestedModule] = moduleRestrictions;
61
- context.report({
62
- node: specifier,
63
- data: {
64
- restrictedName,
65
- restrictedModule,
66
- suggestedName,
67
- suggestedModule,
68
- },
69
- messageId: 'restrict',
70
- });
71
- }
72
- },
73
- };
74
- },
75
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rule = void 0;
4
+ const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
5
+ const createRule_1 = require("../utils/createRule");
6
+ const messages = {
7
+ restrict: 'Usage of `{{restrictedName}}` from `{{restrictedModule}}` is restricted, use `{{suggestedName}}` from the `{{suggestedModule}}`',
8
+ };
9
+ const RESTRICTIONS = {
10
+ '@material-ui/lab': {
11
+ Alert: ['Alert', '@superdispatch/ui-lab'],
12
+ },
13
+ '@material-ui/core': {
14
+ Grid: ['Columns', '@superdispatch/ui-lab'],
15
+ Box: ['Box', '@superdispatch/ui-lab'],
16
+ Button: ['Button', '@superdispatch/ui-lab'],
17
+ Snackbar: ['Snackbar', '@superdispatch/ui'],
18
+ SnackbarContent: ['SnackbarContent', '@superdispatch/ui'],
19
+ },
20
+ '@superdispatch/ui': {
21
+ Button: ['Button', '@superdispatch/ui-lab'],
22
+ GridStack: ['Stack', '@superdispatch/ui'],
23
+ InlineGrid: ['Inline', '@superdispatch/ui'],
24
+ DescriptionList: ['Stack', '@superdispatch/ui-lab'],
25
+ DescriptionListItem: ['DescriptionItem', '@superdispatch/ui-lab'],
26
+ },
27
+ };
28
+ exports.rule = (0, createRule_1.createRule)({
29
+ name: 'no-restricted-modules',
30
+ defaultOptions: [],
31
+ meta: {
32
+ messages,
33
+ type: 'problem',
34
+ fixable: 'code',
35
+ docs: {
36
+ recommended: 'error',
37
+ description: 'Disallows to use Material UI modules',
38
+ },
39
+ schema: [],
40
+ },
41
+ create(context) {
42
+ return {
43
+ ImportDeclaration(node) {
44
+ const { value: restrictedModule } = node.source;
45
+ if (typeof restrictedModule != 'string')
46
+ return;
47
+ const packageRestrictions = RESTRICTIONS[restrictedModule];
48
+ if (!packageRestrictions)
49
+ return;
50
+ for (const specifier of node.specifiers) {
51
+ if (specifier.type === experimental_utils_1.AST_NODE_TYPES.ImportNamespaceSpecifier) {
52
+ continue;
53
+ }
54
+ const restrictedName = specifier.type === experimental_utils_1.AST_NODE_TYPES.ImportDefaultSpecifier
55
+ ? 'default'
56
+ : specifier.imported.name;
57
+ const moduleRestrictions = packageRestrictions[restrictedName];
58
+ if (!moduleRestrictions)
59
+ continue;
60
+ const [suggestedName, suggestedModule] = moduleRestrictions;
61
+ context.report({
62
+ node: specifier,
63
+ data: {
64
+ restrictedName,
65
+ restrictedModule,
66
+ suggestedName,
67
+ suggestedModule,
68
+ },
69
+ messageId: 'restrict',
70
+ });
71
+ }
72
+ },
73
+ };
74
+ },
75
+ });
@@ -1,2 +1,2 @@
1
- import { ESLintUtils } from '@typescript-eslint/experimental-utils';
2
- export declare const createRule: <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener = import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>({ name, meta, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<TOptions, TMessageIds, TRuleListener>>) => import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<TMessageIds, TOptions, TRuleListener>;
1
+ import { ESLintUtils } from '@typescript-eslint/experimental-utils';
2
+ export declare const createRule: <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener = import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleListener>({ name, meta, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<TOptions, TMessageIds, TRuleListener>>) => import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<TMessageIds, TOptions, TRuleListener>;
@@ -1,5 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRule = void 0;
4
- const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
5
- exports.createRule = experimental_utils_1.ESLintUtils.RuleCreator((ruleName) => `https://github.com/superdispatch/web-ui/blob/main/packages/eslint-plugin/src/rules/${ruleName}.ts`);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createRule = void 0;
4
+ const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
5
+ exports.createRule = experimental_utils_1.ESLintUtils.RuleCreator((ruleName) => `https://github.com/superdispatch/web-ui/blob/main/packages/eslint-plugin/src/rules/${ruleName}.ts`);
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 Super Dispatch
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.