eslint-plugin-gamut 3.0.3-alpha.8432ac.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/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/README.md +18 -0
- package/dist/createRule.d.ts +14 -0
- package/dist/createRule.js +6 -0
- package/dist/createRule.js.map +1 -0
- package/dist/file.d.ts +0 -0
- package/dist/file.js +2 -0
- package/dist/file.js.map +1 -0
- package/dist/gamut-import-paths.d.ts +5 -0
- package/dist/gamut-import-paths.js +60 -0
- package/dist/gamut-import-paths.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/no-css-standalone.d.ts +4 -0
- package/dist/no-css-standalone.js +29 -0
- package/dist/no-css-standalone.js.map +1 -0
- package/dist/no-css-standalone.test.d.ts +1 -0
- package/dist/no-css-standalone.test.js +66 -0
- package/dist/no-css-standalone.test.js.map +1 -0
- package/dist/prefer-themed.d.ts +4 -0
- package/dist/prefer-themed.js +67 -0
- package/dist/prefer-themed.js.map +1 -0
- package/dist/prefer-themed.test.d.ts +1 -0
- package/dist/prefer-themed.test.js +43 -0
- package/dist/prefer-themed.test.js.map +1 -0
- package/dist/recommended.d.ts +8 -0
- package/dist/recommended.js +9 -0
- package/dist/recommended.js.map +1 -0
- package/jest.config.js +4 -0
- package/package.json +39 -0
- package/tsconfig.json +8 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
### 3.0.3-alpha.8432ac.0 (2022-01-28)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package eslint-plugin-gamut
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Ryzac, Inc.
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# `gamut-tests`
|
|
2
|
+
|
|
3
|
+
Shared component test setup for Gamut applications. ✨
|
|
4
|
+
|
|
5
|
+
A wrapper around [`component-test-setup`](https://github.com/Codecademy/component-test-setup) that wraps the node with an `@emotion/react`+`gamut-styles` `<ThemeProvider theme={theme}>`.
|
|
6
|
+
Use this instead of `component-test-setup` to test Gamut components in Gamut apps!
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
The API is functionally the same `component-test-setup`:
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { setupRtl } from '@codecademy/gamut-tests';
|
|
14
|
+
|
|
15
|
+
const renderView = setupRtl(MyComponent, { prop: true });
|
|
16
|
+
|
|
17
|
+
const { view } = renderView();
|
|
18
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
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, defaultOptions, create, }: Readonly<{
|
|
2
|
+
name: string;
|
|
3
|
+
meta: {
|
|
4
|
+
docs: {
|
|
5
|
+
description: string;
|
|
6
|
+
recommended: false | "error" | "warn";
|
|
7
|
+
suggestion?: boolean | undefined;
|
|
8
|
+
requiresTypeChecking?: boolean | undefined;
|
|
9
|
+
extendsBaseRule?: string | boolean | undefined;
|
|
10
|
+
};
|
|
11
|
+
} & Omit<import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleMetaData<TMessageIds>, "docs">;
|
|
12
|
+
defaultOptions: Readonly<TOptions>;
|
|
13
|
+
create: (context: Readonly<import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleContext<TMessageIds, TOptions>>, optionsWithDefault: Readonly<TOptions>) => TRuleListener;
|
|
14
|
+
}>) => import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<TMessageIds, TOptions, TRuleListener>;
|
|
@@ -0,0 +1,6 @@
|
|
|
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(name => `https://example.com/rule/${name}`);
|
|
6
|
+
//# sourceMappingURL=createRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRule.js","sourceRoot":"","sources":["../src/createRule.ts"],"names":[],"mappings":";;;AAAA,8EAAoE;AAEvD,QAAA,UAAU,GAAG,gCAAW,CAAC,WAAW,CAC/C,IAAI,CAAC,EAAE,CAAC,4BAA4B,IAAI,EAAE,CAC3C,CAAC"}
|
package/dist/file.d.ts
ADDED
|
File without changes
|
package/dist/file.js
ADDED
package/dist/file.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TSESTree } from '@typescript-eslint/experimental-utils';
|
|
2
|
+
declare const _default: import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"removeDist" | "removeSrc" | "useRelativeImport", never[], {
|
|
3
|
+
'ImportDeclaration[source.value=/(^@)codecademy(\\u002F)gamut/]': (node: TSESTree.ImportDeclaration) => void;
|
|
4
|
+
}>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const createRule_1 = require("./createRule");
|
|
4
|
+
exports.default = (0, createRule_1.createRule)({
|
|
5
|
+
create(context) {
|
|
6
|
+
return {
|
|
7
|
+
'ImportDeclaration[source.value=/(^@)codecademy(\\u002F)gamut/]': function (node) {
|
|
8
|
+
const filename = context.getFilename();
|
|
9
|
+
const importPath = node.source.value;
|
|
10
|
+
const fileDirectory = filename.split('/packages/')[1].split('/')[0];
|
|
11
|
+
const importPackage = importPath.split('@codecademy/')[1].split('/')[0];
|
|
12
|
+
if (fileDirectory === importPackage) {
|
|
13
|
+
context.report({
|
|
14
|
+
messageId: 'useRelativeImport',
|
|
15
|
+
node,
|
|
16
|
+
});
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (importPath.includes('/src')) {
|
|
20
|
+
const indexOfSrc = node.source.range[0] + importPath.search('/src');
|
|
21
|
+
context.report({
|
|
22
|
+
...(importPath.endsWith('/src') && { fix: (fixer) => {
|
|
23
|
+
return fixer.removeRange([indexOfSrc + 1, node.range[1] - 2]);
|
|
24
|
+
} }),
|
|
25
|
+
messageId: 'removeSrc',
|
|
26
|
+
node,
|
|
27
|
+
});
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (importPath.includes('/dist')) {
|
|
31
|
+
const indexOfDist = node.source.range[0] + importPath.search('/dist');
|
|
32
|
+
context.report({
|
|
33
|
+
...(importPath.endsWith('/dist')) && { fix: (fixer) => {
|
|
34
|
+
return fixer.removeRange([indexOfDist + 1, node.range[1] - 2]);
|
|
35
|
+
} },
|
|
36
|
+
messageId: 'removeDist',
|
|
37
|
+
node,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
defaultOptions: [],
|
|
44
|
+
meta: {
|
|
45
|
+
docs: {
|
|
46
|
+
description: 'Ensure Gamut import statements have proper module paths.',
|
|
47
|
+
recommended: 'error',
|
|
48
|
+
},
|
|
49
|
+
fixable: 'code',
|
|
50
|
+
messages: {
|
|
51
|
+
removeDist: 'There is no need to append /dist to the end of this module path.',
|
|
52
|
+
removeSrc: 'There is no need to append /src to the end of this module path.',
|
|
53
|
+
useRelativeImport: 'Use a relative path for this import statement.',
|
|
54
|
+
},
|
|
55
|
+
type: 'suggestion',
|
|
56
|
+
schema: [],
|
|
57
|
+
},
|
|
58
|
+
name: 'gamut-import-paths',
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=gamut-import-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gamut-import-paths.js","sourceRoot":"","sources":["../src/gamut-import-paths.ts"],"names":[],"mappings":";;AAGA,6CAA0C;AAE1C,kBAAe,IAAA,uBAAU,EAAC;IACxB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,gEAAgE,EAAE,UAChE,IAA+B;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AC,OAAO,CAAC,CAAC;oBACpD,OAAO,CAAC,MAAM,CAAC;wBACb,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE;gCACjD,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,WAAW,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;4BACnE,CAAC,EAAC;wBACF,SAAS,EAAE,YAAY;wBACvB,IAAI;qBACL,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC;IACJ,CAAC;IACD,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,0DAA0D;YACvE,WAAW,EAAE,OAAO;SACrB;QACD,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE;YACR,UAAU,EACR,kEAAkE;YACpE,SAAS,EACP,iEAAiE;YACnE,iBAAiB,EAAE,gDAAgD;SACpE;QACD,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,EAAE;KACX;IACD,IAAI,EAAE,oBAAoB;CAC3B,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import recommended from './recommended';
|
|
2
|
+
declare const rules: {
|
|
3
|
+
'import-paths': import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"removeDist" | "removeSrc" | "useRelativeImport", never[], {
|
|
4
|
+
'ImportDeclaration[source.value=/(^@)codecademy(\\u002F)gamut/]': (node: import("@typescript-eslint/types/dist/ast-spec").ImportDeclaration) => void;
|
|
5
|
+
}>;
|
|
6
|
+
'no-css-standalone': import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"noCssStandalone", never[], {
|
|
7
|
+
'ImportDeclaration[source.value=/.*\\.s?css/]': (node: never) => void;
|
|
8
|
+
}>;
|
|
9
|
+
'prefer-themed': import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"preferThemed", never[], {
|
|
10
|
+
TaggedTemplateExpression(node: import("@typescript-eslint/types/dist/ast-spec").TaggedTemplateExpression): void;
|
|
11
|
+
}>;
|
|
12
|
+
};
|
|
13
|
+
export { rules, recommended };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.recommended = exports.rules = void 0;
|
|
7
|
+
const gamut_import_paths_1 = __importDefault(require("./gamut-import-paths"));
|
|
8
|
+
const no_css_standalone_1 = __importDefault(require("./no-css-standalone"));
|
|
9
|
+
const prefer_themed_1 = __importDefault(require("./prefer-themed"));
|
|
10
|
+
const recommended_1 = __importDefault(require("./recommended"));
|
|
11
|
+
exports.recommended = recommended_1.default;
|
|
12
|
+
const rules = {
|
|
13
|
+
'import-paths': gamut_import_paths_1.default,
|
|
14
|
+
'no-css-standalone': no_css_standalone_1.default,
|
|
15
|
+
'prefer-themed': prefer_themed_1.default,
|
|
16
|
+
};
|
|
17
|
+
exports.rules = rules;
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;AAAA,8EAAoD;AACpD,4EAAkD;AAClD,oEAA2C;AAC3C,gEAAwC;AAQxB,sBART,qBAAW,CAQS;AAN3B,MAAM,KAAK,GAAG;IACZ,cAAc,EAAE,4BAAgB;IAChC,mBAAmB,EAAE,2BAAe;IACpC,eAAe,EAAE,uBAAY;CAC9B,CAAC;AAEO,sBAAK"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const createRule_1 = require("./createRule");
|
|
4
|
+
exports.default = (0, createRule_1.createRule)({
|
|
5
|
+
create(context) {
|
|
6
|
+
return {
|
|
7
|
+
'ImportDeclaration[source.value=/.*\\.s?css/]': function (node) {
|
|
8
|
+
context.report({
|
|
9
|
+
messageId: 'noCssStandalone',
|
|
10
|
+
node,
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
defaultOptions: [],
|
|
16
|
+
meta: {
|
|
17
|
+
docs: {
|
|
18
|
+
description: 'Ensure no standalone .css or .scss files.',
|
|
19
|
+
recommended: 'error',
|
|
20
|
+
},
|
|
21
|
+
messages: {
|
|
22
|
+
noCssStandalone: "Don't create anymore stylesheets, please see (insert url here) for current best practices`.",
|
|
23
|
+
},
|
|
24
|
+
type: 'suggestion',
|
|
25
|
+
schema: [],
|
|
26
|
+
},
|
|
27
|
+
name: 'no-css-standalone',
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=no-css-standalone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-css-standalone.js","sourceRoot":"","sources":["../src/no-css-standalone.ts"],"names":[],"mappings":";;AAAA,6CAA0C;AAE1C,kBAAe,IAAA,uBAAU,EAAC;IACxB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,8CAA8C,EAAE,UAAU,IAAI;gBAC5D,OAAO,CAAC,MAAM,CAAC;oBACb,SAAS,EAAE,iBAAiB;oBAC5B,IAAI;iBACL,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;IACD,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,2CAA2C;YACxD,WAAW,EAAE,OAAO;SACrB;QACD,QAAQ,EAAE;YACR,eAAe,EACb,6FAA6F;SAChG;QACD,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,EAAE;KACX;IACD,IAAI,EAAE,mBAAmB;CAC1B,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
|
|
7
|
+
const no_css_standalone_1 = __importDefault(require("./no-css-standalone"));
|
|
8
|
+
const ruleTester = new experimental_utils_1.ESLintUtils.RuleTester({
|
|
9
|
+
parser: '@typescript-eslint/parser',
|
|
10
|
+
});
|
|
11
|
+
ruleTester.run('no-css-standalone', no_css_standalone_1.default, {
|
|
12
|
+
valid: [
|
|
13
|
+
``,
|
|
14
|
+
`import {namedImport} from 'fileName.tsx'`,
|
|
15
|
+
`import {namedImport} from 'fileName.ts'`,
|
|
16
|
+
`import {namedImport} from 'fileName.js'`,
|
|
17
|
+
`import {namedImport} from 'fileName.yml'`,
|
|
18
|
+
`import {namedImport} from 'fileName.json'`,
|
|
19
|
+
`import {namedImport} from 'fileName.md'`,
|
|
20
|
+
`import {namedImport} from 'fileName.mdx'`,
|
|
21
|
+
`import defaultImport from 'fileName.svg'`,
|
|
22
|
+
`import defaultImport from 'fileName.ts'`,
|
|
23
|
+
`import defaultImport from 'fileName.tsx'`,
|
|
24
|
+
`import defaultImport from 'fileName.js'`,
|
|
25
|
+
`import defaultImport from 'fileName.yml'`,
|
|
26
|
+
`import defaultImport from 'fileName.json'`,
|
|
27
|
+
`import defaultImport from 'fileName.md'`,
|
|
28
|
+
`import defaultImport from 'fileName.mdx'`,
|
|
29
|
+
`import defaultImport from 'fileName.svg'`,
|
|
30
|
+
],
|
|
31
|
+
invalid: [
|
|
32
|
+
{
|
|
33
|
+
code: `import {namedImport} from 'fileName.css'`,
|
|
34
|
+
errors: [
|
|
35
|
+
{
|
|
36
|
+
messageId: 'noCssStandalone',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
code: `import {namedImport} from 'fileName.scss'`,
|
|
42
|
+
errors: [
|
|
43
|
+
{
|
|
44
|
+
messageId: 'noCssStandalone',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
code: `import namedImport from 'fileName.css'`,
|
|
50
|
+
errors: [
|
|
51
|
+
{
|
|
52
|
+
messageId: 'noCssStandalone',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
code: `import namedImport from 'fileName.scss'`,
|
|
58
|
+
errors: [
|
|
59
|
+
{
|
|
60
|
+
messageId: 'noCssStandalone',
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=no-css-standalone.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-css-standalone.test.js","sourceRoot":"","sources":["../src/no-css-standalone.test.ts"],"names":[],"mappings":";;;;;AAAA,8EAAoE;AAEpE,4EAAuC;AAEvC,MAAM,UAAU,GAAG,IAAI,gCAAW,CAAC,UAAU,CAAC;IAC5C,MAAM,EAAE,2BAA2B;CACpC,CAAC,CAAC;AAEH,UAAU,CAAC,GAAG,CAAC,mBAAmB,EAAE,2BAAI,EAAE;IACxC,KAAK,EAAE;QACL,EAAE;QACF,0CAA0C;QAC1C,yCAAyC;QACzC,yCAAyC;QACzC,0CAA0C;QAC1C,2CAA2C;QAC3C,yCAAyC;QACzC,0CAA0C;QAC1C,0CAA0C;QAC1C,yCAAyC;QACzC,0CAA0C;QAC1C,yCAAyC;QACzC,0CAA0C;QAC1C,2CAA2C;QAC3C,yCAAyC;QACzC,0CAA0C;QAC1C,0CAA0C;KAC3C;IACD,OAAO,EAAE;QACP;YACE,IAAI,EAAE,0CAA0C;YAChD,MAAM,EAAE;gBACN;oBACE,SAAS,EAAE,iBAAiB;iBAC7B;aACF;SACF;QACD;YACE,IAAI,EAAE,2CAA2C;YACjD,MAAM,EAAE;gBACN;oBACE,SAAS,EAAE,iBAAiB;iBAC7B;aACF;SACF;QACD;YACE,IAAI,EAAE,wCAAwC;YAC9C,MAAM,EAAE;gBACN;oBACE,SAAS,EAAE,iBAAiB;iBAC7B;aACF;SACF;QACD;YACE,IAAI,EAAE,yCAAyC;YAC/C,MAAM,EAAE;gBACN;oBACE,SAAS,EAAE,iBAAiB;iBAC7B;aACF;SACF;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const _default: import("@typescript-eslint/experimental-utils/dist/ts-eslint/Rule").RuleModule<"preferThemed", never[], {
|
|
2
|
+
TaggedTemplateExpression(node: import("@typescript-eslint/types/dist/ast-spec").TaggedTemplateExpression): void;
|
|
3
|
+
}>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
|
|
4
|
+
const createRule_1 = require("./createRule");
|
|
5
|
+
exports.default = (0, createRule_1.createRule)({
|
|
6
|
+
// @to-do: create helper function to get node
|
|
7
|
+
create(context) {
|
|
8
|
+
return {
|
|
9
|
+
TaggedTemplateExpression(node) {
|
|
10
|
+
if (node.tag.type === experimental_utils_1.AST_NODE_TYPES.MemberExpression) {
|
|
11
|
+
if (node.tag.object.type !== 'Identifier')
|
|
12
|
+
return;
|
|
13
|
+
const expressionVariable = node.tag.object.name;
|
|
14
|
+
const arrowFuncExpression = node.quasi.expressions[0];
|
|
15
|
+
if (arrowFuncExpression?.type !== experimental_utils_1.AST_NODE_TYPES.ArrowFunctionExpression)
|
|
16
|
+
return;
|
|
17
|
+
const argObject = arrowFuncExpression.params[0];
|
|
18
|
+
if (argObject?.type !== experimental_utils_1.AST_NODE_TYPES.ObjectPattern)
|
|
19
|
+
return;
|
|
20
|
+
const argumentVariable = argObject.properties[0].value;
|
|
21
|
+
if (argumentVariable?.type !== experimental_utils_1.AST_NODE_TYPES.Identifier)
|
|
22
|
+
return;
|
|
23
|
+
const namedArgumentVariable = argumentVariable.name;
|
|
24
|
+
if (expressionVariable === 'styled' &&
|
|
25
|
+
namedArgumentVariable === 'theme') {
|
|
26
|
+
// TURN INTO UTILITY FUNCTION
|
|
27
|
+
if (arrowFuncExpression.body.type !== experimental_utils_1.AST_NODE_TYPES.MemberExpression)
|
|
28
|
+
return;
|
|
29
|
+
if (arrowFuncExpression.body.object.type !==
|
|
30
|
+
experimental_utils_1.AST_NODE_TYPES.MemberExpression)
|
|
31
|
+
return;
|
|
32
|
+
if (arrowFuncExpression.body.property.type !==
|
|
33
|
+
experimental_utils_1.AST_NODE_TYPES.Identifier)
|
|
34
|
+
return;
|
|
35
|
+
if (arrowFuncExpression.body.object.property.type !==
|
|
36
|
+
experimental_utils_1.AST_NODE_TYPES.Identifier)
|
|
37
|
+
return;
|
|
38
|
+
const themeValueKey = arrowFuncExpression.body.property.name;
|
|
39
|
+
const themeCategory = arrowFuncExpression.body.object.property.name;
|
|
40
|
+
context.report({
|
|
41
|
+
fix: (fixer) => {
|
|
42
|
+
return fixer.replaceText(arrowFuncExpression, `themed('${themeCategory}.${themeValueKey}')`);
|
|
43
|
+
},
|
|
44
|
+
messageId: 'preferThemed',
|
|
45
|
+
node,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
defaultOptions: [],
|
|
53
|
+
meta: {
|
|
54
|
+
docs: {
|
|
55
|
+
description: 'Prefer themed style utility',
|
|
56
|
+
recommended: 'error',
|
|
57
|
+
},
|
|
58
|
+
fixable: 'code',
|
|
59
|
+
messages: {
|
|
60
|
+
preferThemed: 'Use the themed(url) style utility instead.',
|
|
61
|
+
},
|
|
62
|
+
type: 'suggestion',
|
|
63
|
+
schema: [],
|
|
64
|
+
},
|
|
65
|
+
name: 'prefer-themed',
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=prefer-themed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-themed.js","sourceRoot":"","sources":["../src/prefer-themed.ts"],"names":[],"mappings":";;AAAA,8EAAuE;AAEvE,6CAA0C;AAE1C,kBAAe,IAAA,uBAAU,EAAC;IACxB,6CAA6C;IAE7C,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,wBAAwB,CAAC,IAAI;gBAC3B,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,mCAAc,CAAC,gBAAgB,EAAE;oBACrD,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY;wBAAE,OAAO;oBAClD,MAAM,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;oBAChD,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;oBAEtD,IACE,mBAAmB,EAAE,IAAI,KAAK,mCAAc,CAAC,uBAAuB;wBAEpE,OAAO;oBACT,MAAM,SAAS,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;oBAEhD,IAAI,SAAS,EAAE,IAAI,KAAK,mCAAc,CAAC,aAAa;wBAAE,OAAO;oBAC7D,MAAM,gBAAgB,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;oBAEvD,IAAI,gBAAgB,EAAE,IAAI,KAAK,mCAAc,CAAC,UAAU;wBAAE,OAAO;oBACjE,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,IAAI,CAAC;oBAEpD,IACE,kBAAkB,KAAK,QAAQ;wBAC/B,qBAAqB,K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
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
|
|
7
|
+
const prefer_themed_1 = __importDefault(require("./prefer-themed"));
|
|
8
|
+
const ruleTester = new experimental_utils_1.ESLintUtils.RuleTester({
|
|
9
|
+
parser: '@typescript-eslint/parser',
|
|
10
|
+
});
|
|
11
|
+
ruleTester.run('prefer-themed', prefer_themed_1.default, {
|
|
12
|
+
valid: [
|
|
13
|
+
``,
|
|
14
|
+
`styled.div\`
|
|
15
|
+
color: \${themed('colors.wat')};
|
|
16
|
+
\``,
|
|
17
|
+
`styled(Box)\`
|
|
18
|
+
color: \${themed('colors.wat')};
|
|
19
|
+
\``,
|
|
20
|
+
`
|
|
21
|
+
export const AppWrapper = styled.div\`
|
|
22
|
+
position: relative;
|
|
23
|
+
z-index: 1;
|
|
24
|
+
\`;
|
|
25
|
+
`,
|
|
26
|
+
],
|
|
27
|
+
invalid: [
|
|
28
|
+
{
|
|
29
|
+
code: `styled.div\`
|
|
30
|
+
color: \${({ theme }) => theme.colors.wat};
|
|
31
|
+
\``,
|
|
32
|
+
errors: [
|
|
33
|
+
{
|
|
34
|
+
messageId: 'preferThemed',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
output: `styled.div\`
|
|
38
|
+
color: \${themed('colors.wat')};
|
|
39
|
+
\``,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=prefer-themed.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-themed.test.js","sourceRoot":"","sources":["../src/prefer-themed.test.ts"],"names":[],"mappings":";;;;;AAAA,8EAAoE;AAEpE,oEAAmC;AAEnC,MAAM,UAAU,GAAG,IAAI,gCAAW,CAAC,UAAU,CAAC;IAC5C,MAAM,EAAE,2BAA2B;CACpC,CAAC,CAAC;AAEH,UAAU,CAAC,GAAG,CAAC,eAAe,EAAE,uBAAI,EAAE;IACpC,KAAK,EAAE;QACL,EAAE;QACF;;GAED;QACC;;GAED;QACC;;;;;CAKH;KACE;IACD,OAAO,EAAE;QACP;YACE,IAAI,EAAE;;GAET;YACG,MAAM,EAAE;gBACN;oBACE,SAAS,EAAE,cAAc;iBAC1B;aACF;YACD,MAAM,EAAE;;GAEX;SACE;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../src/recommended.ts"],"names":[],"mappings":";AAAA,iBAAS;IACP,KAAK,EAAE;QACL,uCAAuC,EAAE,KAAK;QAC9C,mCAAmC,EAAE,KAAK;QAC1C,wCAAwC,EAAE,OAAO;KAClD;CACF,CAAC"}
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
3
|
+
"description": "Shared eslint plugin for Gamut applications",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"gamut",
|
|
6
|
+
"eslint",
|
|
7
|
+
"styles",
|
|
8
|
+
"gamut-styles"
|
|
9
|
+
],
|
|
10
|
+
"name": "eslint-plugin-gamut",
|
|
11
|
+
"version": "3.0.3-alpha.8432ac.0",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"module": "dist/index.js",
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/Codecademy/gamut.git"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"verify": "tsc --noEmit",
|
|
24
|
+
"build:compile": "tsc",
|
|
25
|
+
"build:clean": "rm -rf dist",
|
|
26
|
+
"build": "yarn build:clean && yarn build:compile",
|
|
27
|
+
"lernaBuildTask": "yarn build"
|
|
28
|
+
},
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@types/eslint": "^8.2.1",
|
|
32
|
+
"@typescript-eslint/experimental-utils": "^5.7.0",
|
|
33
|
+
"eslint": "^8.4.1"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/eslint": "^8.2.1"
|
|
37
|
+
},
|
|
38
|
+
"gitHead": "97a90092a9f75f47629987e0df8372037e4ff84a"
|
|
39
|
+
}
|