eslint-plugin-gamut 2.4.4-alpha.e3cc4a.0 → 2.4.4-alpha.e426ef.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 +4 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/no-raw-z-index.d.ts +6 -0
- package/dist/no-raw-z-index.js +55 -0
- package/dist/no-raw-z-index.js.map +1 -0
- package/dist/recommended.d.ts +1 -0
- package/dist/recommended.js +1 -0
- package/dist/recommended.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ declare const rules: {
|
|
|
12
12
|
'no-kbd-element': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noKbdElement", [], {
|
|
13
13
|
JSXOpeningElement(node: import("@typescript-eslint/types/dist/generated/ast-spec").JSXOpeningElement): void;
|
|
14
14
|
}>;
|
|
15
|
+
'no-raw-z-index': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noRawZIndex", [], {
|
|
16
|
+
Property(node: import("@typescript-eslint/types/dist/generated/ast-spec").Property): void;
|
|
17
|
+
JSXAttribute(node: import("@typescript-eslint/types/dist/generated/ast-spec").JSXAttribute): void;
|
|
18
|
+
}>;
|
|
15
19
|
'prefer-themed': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"preferThemed", [], {
|
|
16
20
|
TaggedTemplateExpression(node: import("@typescript-eslint/types/dist/generated/ast-spec").TaggedTemplateExpression): void;
|
|
17
21
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const gamut_import_paths_1 = __importDefault(require("./gamut-import-paths"));
|
|
|
8
8
|
const no_css_standalone_1 = __importDefault(require("./no-css-standalone"));
|
|
9
9
|
const no_inline_style_1 = __importDefault(require("./no-inline-style"));
|
|
10
10
|
const no_kbd_element_1 = __importDefault(require("./no-kbd-element"));
|
|
11
|
+
const no_raw_z_index_1 = __importDefault(require("./no-raw-z-index"));
|
|
11
12
|
const prefer_themed_1 = __importDefault(require("./prefer-themed"));
|
|
12
13
|
const recommended_1 = __importDefault(require("./recommended"));
|
|
13
14
|
exports.recommended = recommended_1.default;
|
|
@@ -16,6 +17,7 @@ const rules = {
|
|
|
16
17
|
'no-css-standalone': no_css_standalone_1.default,
|
|
17
18
|
'no-inline-style': no_inline_style_1.default,
|
|
18
19
|
'no-kbd-element': no_kbd_element_1.default,
|
|
20
|
+
'no-raw-z-index': no_raw_z_index_1.default,
|
|
19
21
|
'prefer-themed': prefer_themed_1.default,
|
|
20
22
|
};
|
|
21
23
|
exports.rules = rules;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;AAAA,8EAAoD;AACpD,4EAAkD;AAClD,wEAA8C;AAC9C,sEAA4C;AAC5C,oEAA2C;AAC3C,gEAAwC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;AAAA,8EAAoD;AACpD,4EAAkD;AAClD,wEAA8C;AAC9C,sEAA4C;AAC5C,sEAA2C;AAC3C,oEAA2C;AAC3C,gEAAwC;AAWxB,sBAXT,qBAAW,CAWS;AAT3B,MAAM,KAAK,GAAG;IACZ,cAAc,EAAE,4BAAgB;IAChC,mBAAmB,EAAE,2BAAe;IACpC,iBAAiB,EAAE,yBAAa;IAChC,gBAAgB,EAAE,wBAAY;IAC9B,gBAAgB,EAAE,wBAAW;IAC7B,eAAe,EAAE,uBAAY;CAC9B,CAAC;AAEO,sBAAK"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
declare const _default: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"noRawZIndex", [], {
|
|
3
|
+
Property(node: TSESTree.Property): void;
|
|
4
|
+
JSXAttribute(node: TSESTree.JSXAttribute): void;
|
|
5
|
+
}>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
4
|
+
const createRule_1 = require("./createRule");
|
|
5
|
+
/**
|
|
6
|
+
* True for a numeric literal, including a negated one like `-1`.
|
|
7
|
+
*/
|
|
8
|
+
const isNumericLiteral = (node) => {
|
|
9
|
+
if (!node)
|
|
10
|
+
return false;
|
|
11
|
+
if (node.type === utils_1.AST_NODE_TYPES.Literal && typeof node.value === 'number') {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return (node.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
|
|
15
|
+
(node.operator === '-' || node.operator === '+') &&
|
|
16
|
+
isNumericLiteral(node.argument));
|
|
17
|
+
};
|
|
18
|
+
const isZIndexKey = (key) => (key.type === utils_1.AST_NODE_TYPES.Identifier && key.name === 'zIndex') ||
|
|
19
|
+
(key.type === utils_1.AST_NODE_TYPES.Literal && key.value === 'zIndex') ||
|
|
20
|
+
(key.type === utils_1.AST_NODE_TYPES.Literal && key.value === 'z-index');
|
|
21
|
+
exports.default = (0, createRule_1.createRule)({
|
|
22
|
+
create(context) {
|
|
23
|
+
return {
|
|
24
|
+
// Style objects: `{ zIndex: 1 }` / `{ 'z-index': 1 }`
|
|
25
|
+
Property(node) {
|
|
26
|
+
if (isZIndexKey(node.key) && isNumericLiteral(node.value)) {
|
|
27
|
+
context.report({ messageId: 'noRawZIndex', node: node.value });
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
// JSX props: `<Box zIndex={1} />`
|
|
31
|
+
JSXAttribute(node) {
|
|
32
|
+
if (node.name.type === utils_1.AST_NODE_TYPES.JSXIdentifier &&
|
|
33
|
+
node.name.name === 'zIndex' &&
|
|
34
|
+
node.value?.type === utils_1.AST_NODE_TYPES.JSXExpressionContainer &&
|
|
35
|
+
isNumericLiteral(node.value.expression)) {
|
|
36
|
+
context.report({ messageId: 'noRawZIndex', node: node.value });
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
defaultOptions: [],
|
|
42
|
+
meta: {
|
|
43
|
+
docs: {
|
|
44
|
+
description: 'Discourage raw numeric z-index values which can lead to z-index stacking issues and encourage usage of semantic tokens from the `zIndices` scale.',
|
|
45
|
+
recommended: 'error',
|
|
46
|
+
},
|
|
47
|
+
messages: {
|
|
48
|
+
noRawZIndex: 'Semantic tokens from the `zIndices` scale (e.g. `zIndices.modal`) are recommendedinstead of a raw z-index number. For a deliberate in-between value, disable this rule inline with a justifying comment.',
|
|
49
|
+
},
|
|
50
|
+
type: 'suggestion',
|
|
51
|
+
schema: [],
|
|
52
|
+
},
|
|
53
|
+
name: 'no-raw-z-index',
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=no-raw-z-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-raw-z-index.js","sourceRoot":"","sources":["../src/no-raw-z-index.ts"],"names":[],"mappings":";;AAAA,oDAAoE;AAEpE,6CAA0C;AAE1C;;GAEG;AACH,MAAM,gBAAgB,GAAG,CAAC,IAAsC,EAAW,EAAE;IAC3E,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACxB,IAAI,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,OAAO,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3E,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,eAAe;QAC5C,CAAC,IAAI,CAAC,QAAQ,KAAK,GAAG,IAAI,IAAI,CAAC,QAAQ,KAAK,GAAG,CAAC;QAChD,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAChC,CAAC;AACJ,CAAC,CA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mJ;YACrJ,WAAW,EAAE,OAAO;SACrB;QACD,QAAQ,EAAE;YACR,WAAW,EACT,0MAA0M;SAC7M;QACD,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,EAAE;KACX;IACD,IAAI,EAAE,gBAAgB;CACvB,CAAC,CAAC"}
|
package/dist/recommended.d.ts
CHANGED
package/dist/recommended.js
CHANGED
package/dist/recommended.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../src/recommended.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACb,KAAK,EAAE;QACL,yBAAyB,EAAE,OAAO;QAClC,uBAAuB,EAAE,OAAO;QAChC,qBAAqB,EAAE,KAAK;QAC5B,0BAA0B,EAAE,OAAO;KACpC;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../src/recommended.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACb,KAAK,EAAE;QACL,yBAAyB,EAAE,OAAO;QAClC,uBAAuB,EAAE,OAAO;QAChC,sBAAsB,EAAE,OAAO;QAC/B,qBAAqB,EAAE,KAAK;QAC5B,0BAA0B,EAAE,OAAO;KACpC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-gamut",
|
|
3
3
|
"description": "Shared eslint plugin for Gamut applications",
|
|
4
|
-
"version": "2.4.4-alpha.
|
|
4
|
+
"version": "2.4.4-alpha.e426ef.0",
|
|
5
5
|
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@typescript-eslint/utils": "^5.15.0"
|