@atlaskit/eslint-plugin-platform 0.7.3 → 0.7.5
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 +16 -0
- package/dist/cjs/index.js +4 -3
- package/dist/cjs/rules/ensure-native-and-af-exports-synced/index.js +0 -3
- package/dist/cjs/rules/no-duplicate-dependencies/index.js +3 -3
- package/dist/cjs/rules/no-module-level-eval-nav4/index.js +56 -0
- package/dist/cjs/rules/utils.js +3 -3
- package/dist/es2019/index.js +4 -3
- package/dist/es2019/rules/ensure-native-and-af-exports-synced/index.js +0 -3
- package/dist/es2019/rules/no-module-level-eval-nav4/index.js +50 -0
- package/dist/esm/index.js +4 -3
- package/dist/esm/rules/ensure-native-and-af-exports-synced/index.js +0 -3
- package/dist/esm/rules/no-duplicate-dependencies/index.js +3 -3
- package/dist/esm/rules/no-module-level-eval-nav4/index.js +50 -0
- package/dist/esm/rules/utils.js +3 -3
- package/dist/types/index.d.ts +2 -1
- package/dist/types-ts4.5/index.d.ts +2 -1
- package/index.js +1 -1
- package/package.json +6 -5
- package/src/index.tsx +7 -3
- package/src/rules/ensure-native-and-af-exports-synced/index.tsx +0 -3
- package/src/rules/no-module-level-eval-nav4/README.md +8 -0
- package/src/rules/no-module-level-eval-nav4/__tests__/test.tsx +130 -0
- package/src/rules/no-module-level-eval-nav4/index.tsx +72 -0
- package/dist/cjs/rules/ensure-valid-emotion-css-prop/index.js +0 -91
- package/dist/es2019/rules/ensure-valid-emotion-css-prop/index.js +0 -87
- package/dist/esm/rules/ensure-valid-emotion-css-prop/index.js +0 -85
- package/src/rules/ensure-valid-emotion-css-prop/__tests__/unit/rule.test.ts +0 -142
- package/src/rules/ensure-valid-emotion-css-prop/index.ts +0 -96
- /package/dist/types/rules/{ensure-valid-emotion-css-prop → no-module-level-eval-nav4}/index.d.ts +0 -0
- /package/dist/types-ts4.5/rules/{ensure-valid-emotion-css-prop → no-module-level-eval-nav4}/index.d.ts +0 -0
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
-
import type { Rule } from 'eslint';
|
|
3
|
-
|
|
4
|
-
type Position = {
|
|
5
|
-
line: number;
|
|
6
|
-
column: number;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const rule: Rule.RuleModule = {
|
|
10
|
-
meta: {
|
|
11
|
-
type: 'problem',
|
|
12
|
-
docs: {
|
|
13
|
-
description: 'Ensure valid use of the `css` prop from `@emotion/react`',
|
|
14
|
-
recommended: true,
|
|
15
|
-
},
|
|
16
|
-
messages: {
|
|
17
|
-
noEmotionCssImport: 'Must import `css` from `@emotion/react` when using the `css` prop.',
|
|
18
|
-
noEmotionCssPropFunctionCall:
|
|
19
|
-
'No function calls allowed when passing an object directly to the `css` prop with `@emotion/react`.',
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
create(context) {
|
|
23
|
-
let emotionJsxImported = false;
|
|
24
|
-
let emotionJsxImportPosition: Position | null | undefined;
|
|
25
|
-
let emotionCssImported = false;
|
|
26
|
-
let cssPropExpressonUsed = false;
|
|
27
|
-
|
|
28
|
-
// Ignore files in these directories
|
|
29
|
-
if (/example|__tests__|__fixtures__/.test(context.filename)) {
|
|
30
|
-
return {};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
ImportDeclaration(node) {
|
|
35
|
-
if (node.source.value === '@emotion/react') {
|
|
36
|
-
node.specifiers.forEach((specifier) => {
|
|
37
|
-
if (specifier.type === 'ImportSpecifier') {
|
|
38
|
-
if (specifier.imported.name === 'jsx') {
|
|
39
|
-
emotionJsxImported = true;
|
|
40
|
-
emotionJsxImportPosition = specifier.loc?.start;
|
|
41
|
-
}
|
|
42
|
-
if (specifier.imported.name === 'css') {
|
|
43
|
-
emotionCssImported = true;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
JSXAttribute(node: any) {
|
|
50
|
-
const { name, value } = node;
|
|
51
|
-
|
|
52
|
-
// Only run on emotion css props
|
|
53
|
-
if (!emotionJsxImported) return;
|
|
54
|
-
if (name.name !== 'css') return;
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
value.type === 'JSXExpressionContainer' &&
|
|
58
|
-
value.expression.type === 'ObjectExpression'
|
|
59
|
-
) {
|
|
60
|
-
cssPropExpressonUsed = true;
|
|
61
|
-
let containsFunctionExpression = false;
|
|
62
|
-
|
|
63
|
-
// Iterate over the properties of the object
|
|
64
|
-
value.expression.properties.forEach((prop: any) => {
|
|
65
|
-
// Check for function expressions directly within the object literal
|
|
66
|
-
if (
|
|
67
|
-
prop.value?.type === 'ArrowFunctionExpression' ||
|
|
68
|
-
prop.value?.type === 'FunctionExpression' ||
|
|
69
|
-
prop.value?.type === 'CallExpression'
|
|
70
|
-
) {
|
|
71
|
-
containsFunctionExpression = true;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// If a function expression is found within the direct object literal, report an error
|
|
76
|
-
if (containsFunctionExpression) {
|
|
77
|
-
context.report({
|
|
78
|
-
node,
|
|
79
|
-
messageId: 'noEmotionCssPropFunctionCall',
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
'Program:exit'() {
|
|
85
|
-
if (emotionJsxImported && cssPropExpressonUsed && !emotionCssImported) {
|
|
86
|
-
context.report({
|
|
87
|
-
messageId: 'noEmotionCssImport',
|
|
88
|
-
loc: emotionJsxImportPosition || { line: 1, column: 0 },
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export default rule;
|
/package/dist/types/rules/{ensure-valid-emotion-css-prop → no-module-level-eval-nav4}/index.d.ts
RENAMED
|
File without changes
|
|
File without changes
|