@atlaskit/eslint-plugin-ui-styling-standard 1.4.5 → 1.5.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 +18 -5
- package/README.md +1 -0
- package/dist/cjs/index.codegen.js +3 -3
- package/dist/cjs/presets/all-flat.codegen.js +6 -3
- package/dist/cjs/presets/all.codegen.js +6 -3
- package/dist/cjs/presets/recommended-flat.codegen.js +6 -3
- package/dist/cjs/presets/recommended.codegen.js +6 -3
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/no-important-styles/index.js +95 -28
- package/dist/cjs/rules/no-unsafe-selectors/index.js +1 -1
- package/dist/cjs/rules/no-unsafe-selectors/lint-selector.js +1 -1
- package/dist/cjs/rules/no-unused-cssmap-properties/index.js +192 -0
- package/dist/es2019/index.codegen.js +4 -5
- package/dist/es2019/presets/all-flat.codegen.js +6 -3
- package/dist/es2019/presets/all.codegen.js +6 -3
- package/dist/es2019/presets/recommended-flat.codegen.js +6 -3
- package/dist/es2019/presets/recommended.codegen.js +6 -3
- package/dist/es2019/rules/index.codegen.js +4 -1
- package/dist/es2019/rules/no-important-styles/index.js +65 -13
- package/dist/es2019/rules/no-unsafe-selectors/index.js +1 -1
- package/dist/es2019/rules/no-unsafe-selectors/lint-selector.js +1 -1
- package/dist/es2019/rules/no-unused-cssmap-properties/index.js +182 -0
- package/dist/esm/index.codegen.js +4 -4
- package/dist/esm/presets/all-flat.codegen.js +6 -3
- package/dist/esm/presets/all.codegen.js +6 -3
- package/dist/esm/presets/recommended-flat.codegen.js +6 -3
- package/dist/esm/presets/recommended.codegen.js +6 -3
- package/dist/esm/rules/index.codegen.js +4 -1
- package/dist/esm/rules/no-important-styles/index.js +95 -27
- package/dist/esm/rules/no-unsafe-selectors/index.js +1 -1
- package/dist/esm/rules/no-unsafe-selectors/lint-selector.js +1 -1
- package/dist/esm/rules/no-unused-cssmap-properties/index.js +186 -0
- package/dist/types/index.codegen.d.ts +9 -718
- package/dist/types/presets/all-flat.codegen.d.ts +4 -40
- package/dist/types/presets/all.codegen.d.ts +4 -37
- package/dist/types/presets/recommended-flat.codegen.d.ts +4 -40
- package/dist/types/presets/recommended.codegen.d.ts +4 -37
- package/dist/types/rules/index.codegen.d.ts +7 -19
- package/dist/types/rules/no-unused-cssmap-properties/index.d.ts +3 -0
- package/dist/types/rules/utils/create-rule.d.ts +3 -1
- package/dist/types-ts4.5/index.codegen.d.ts +9 -1078
- package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +4 -61
- package/dist/types-ts4.5/presets/all.codegen.d.ts +4 -61
- package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +4 -61
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +4 -61
- package/dist/types-ts4.5/rules/index.codegen.d.ts +7 -19
- package/dist/types-ts4.5/rules/no-unused-cssmap-properties/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/utils/create-rule.d.ts +3 -1
- package/package.json +3 -7
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::8f28dfef84548edbe33f59201f295cc5>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
const config = {
|
|
7
8
|
plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system'],
|
|
8
9
|
rules: {
|
|
9
10
|
'@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
|
|
@@ -22,6 +23,7 @@ export default {
|
|
|
22
23
|
'@atlaskit/ui-styling-standard/no-styled': 'error',
|
|
23
24
|
'@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
|
|
24
25
|
'@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
|
|
26
|
+
'@atlaskit/ui-styling-standard/no-unused-cssmap-properties': 'warn',
|
|
25
27
|
'@atlaskit/ui-styling-standard/use-compiled': 'error',
|
|
26
28
|
'@atlaskit/design-system/consistent-css-prop-usage': ['error', {
|
|
27
29
|
excludeReactComponents: true,
|
|
@@ -37,4 +39,5 @@ export default {
|
|
|
37
39
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
38
40
|
}]
|
|
39
41
|
}
|
|
40
|
-
};
|
|
42
|
+
};
|
|
43
|
+
export default config;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::f99588f71d6b353cefbed97fd172e433>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
|
+
|
|
6
7
|
import * as atlaskitDesignSystemPlugin from '@atlaskit/eslint-plugin-design-system';
|
|
7
|
-
|
|
8
|
+
const config = {
|
|
8
9
|
plugins: {
|
|
9
10
|
// NOTE: The reference to this plugin is inserted dynamically while creating the plugin in `index.codegen.tsx`
|
|
10
11
|
'@atlaskit/design-system': atlaskitDesignSystemPlugin
|
|
@@ -26,6 +27,7 @@ export default {
|
|
|
26
27
|
'@atlaskit/ui-styling-standard/no-styled': 'error',
|
|
27
28
|
'@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
|
|
28
29
|
'@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
|
|
30
|
+
'@atlaskit/ui-styling-standard/no-unused-cssmap-properties': 'warn',
|
|
29
31
|
'@atlaskit/ui-styling-standard/use-compiled': 'error',
|
|
30
32
|
'@atlaskit/design-system/consistent-css-prop-usage': ['error', {
|
|
31
33
|
excludeReactComponents: true,
|
|
@@ -41,4 +43,5 @@ export default {
|
|
|
41
43
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
42
44
|
}]
|
|
43
45
|
}
|
|
44
|
-
};
|
|
46
|
+
};
|
|
47
|
+
export default config;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::8f28dfef84548edbe33f59201f295cc5>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
const config = {
|
|
7
8
|
plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system'],
|
|
8
9
|
rules: {
|
|
9
10
|
'@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
|
|
@@ -22,6 +23,7 @@ export default {
|
|
|
22
23
|
'@atlaskit/ui-styling-standard/no-styled': 'error',
|
|
23
24
|
'@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
|
|
24
25
|
'@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
|
|
26
|
+
'@atlaskit/ui-styling-standard/no-unused-cssmap-properties': 'warn',
|
|
25
27
|
'@atlaskit/ui-styling-standard/use-compiled': 'error',
|
|
26
28
|
'@atlaskit/design-system/consistent-css-prop-usage': ['error', {
|
|
27
29
|
excludeReactComponents: true,
|
|
@@ -37,4 +39,5 @@ export default {
|
|
|
37
39
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
38
40
|
}]
|
|
39
41
|
}
|
|
40
|
-
};
|
|
42
|
+
};
|
|
43
|
+
export default config;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::2eab912b0c44d0fcbdc2f0b79cb42fa9>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
|
+
|
|
6
7
|
import atlaskitTheme from './atlaskit-theme';
|
|
7
8
|
import convertPropsSyntax from './convert-props-syntax';
|
|
8
9
|
import enforceStyleProp from './enforce-style-prop';
|
|
@@ -19,6 +20,7 @@ import noNestedSelectors from './no-nested-selectors';
|
|
|
19
20
|
import noStyled from './no-styled';
|
|
20
21
|
import noUnsafeSelectors from './no-unsafe-selectors';
|
|
21
22
|
import noUnsafeValues from './no-unsafe-values';
|
|
23
|
+
import noUnusedCssmapProperties from './no-unused-cssmap-properties';
|
|
22
24
|
import useCompiled from './use-compiled';
|
|
23
25
|
export const rules = {
|
|
24
26
|
'atlaskit-theme': atlaskitTheme,
|
|
@@ -37,5 +39,6 @@ export const rules = {
|
|
|
37
39
|
'no-styled': noStyled,
|
|
38
40
|
'no-unsafe-selectors': noUnsafeSelectors,
|
|
39
41
|
'no-unsafe-values': noUnsafeValues,
|
|
42
|
+
'no-unused-cssmap-properties': noUnusedCssmapProperties,
|
|
40
43
|
'use-compiled': useCompiled
|
|
41
44
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import esquery from 'esquery';
|
|
2
1
|
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
3
2
|
import { hasStyleObjectArguments } from '@atlaskit/eslint-utils/is-supported-import';
|
|
4
3
|
import { importSources } from '@atlaskit/eslint-utils/schema';
|
|
@@ -33,31 +32,84 @@ export const rule = createLintRuleWithTypedConfig({
|
|
|
33
32
|
if (!hasStyleObjectArguments(node.callee, references, importSources)) {
|
|
34
33
|
return;
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (match.type !== 'Property') {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (isImportant(match.value)) {
|
|
35
|
+
walkProperties(node, propertyNode => {
|
|
36
|
+
if (isImportant(propertyNode.value)) {
|
|
42
37
|
context.report({
|
|
43
|
-
node:
|
|
38
|
+
node: propertyNode.value,
|
|
44
39
|
messageId: 'no-important-styles'
|
|
45
40
|
});
|
|
46
41
|
}
|
|
47
|
-
}
|
|
42
|
+
});
|
|
48
43
|
}
|
|
49
44
|
};
|
|
50
45
|
}
|
|
51
46
|
});
|
|
52
47
|
export default rule;
|
|
53
|
-
const
|
|
48
|
+
const IMPORTANT_SUFFIX_REGEX = /!\s*important\s*$/;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Walk through all Property nodes in the AST tree recursively.
|
|
52
|
+
* This is faster than esquery for this specific use case as it avoids
|
|
53
|
+
* selector compilation and executes a simple depth-first traversal.
|
|
54
|
+
*/
|
|
55
|
+
function walkProperties(node, callback) {
|
|
56
|
+
var _node$arguments;
|
|
57
|
+
if (node.type === 'Property' && node.value) {
|
|
58
|
+
callback(node);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Iterate through object properties
|
|
62
|
+
if ((_node$arguments = node.arguments) !== null && _node$arguments !== void 0 && _node$arguments.length) {
|
|
63
|
+
for (const arg of node.arguments) {
|
|
64
|
+
if (arg.type === 'ObjectExpression' && arg.properties) {
|
|
65
|
+
for (const prop of arg.properties) {
|
|
66
|
+
walkObjectProperty(prop, callback);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Recursively walk object properties to find nested Property nodes.
|
|
75
|
+
*/
|
|
76
|
+
function walkObjectProperty(node, callback) {
|
|
77
|
+
if (node.type === 'Property') {
|
|
78
|
+
var _node$value;
|
|
79
|
+
callback(node);
|
|
80
|
+
// Recursively check nested objects
|
|
81
|
+
if (((_node$value = node.value) === null || _node$value === void 0 ? void 0 : _node$value.type) === 'ObjectExpression' && node.value.properties) {
|
|
82
|
+
for (const prop of node.value.properties) {
|
|
83
|
+
walkObjectProperty(prop, callback);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Check if a value contains !important flag.
|
|
91
|
+
* Uses fast string checks before regex to avoid regex overhead for common cases.
|
|
92
|
+
*/
|
|
54
93
|
function isImportant(node) {
|
|
55
94
|
if (node.type === 'Literal') {
|
|
56
|
-
|
|
95
|
+
if (typeof node.value !== 'string') {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
// Fast check: string must end with 'important' (after optional whitespace)
|
|
99
|
+
const len = node.value.length;
|
|
100
|
+
if (len < 10) {
|
|
101
|
+
return false;
|
|
102
|
+
} // "!important" is 10 chars minimum
|
|
103
|
+
return IMPORTANT_SUFFIX_REGEX.test(node.value);
|
|
57
104
|
}
|
|
58
105
|
if (node.type === 'TemplateLiteral') {
|
|
59
|
-
|
|
60
|
-
|
|
106
|
+
var _node$quasis;
|
|
107
|
+
if (!((_node$quasis = node.quasis) !== null && _node$quasis !== void 0 && _node$quasis.length)) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
// Only check the last quasi's raw value (most likely to contain the !important)
|
|
111
|
+
const lastQuasi = node.quasis[node.quasis.length - 1];
|
|
112
|
+
return IMPORTANT_SUFFIX_REGEX.test(lastQuasi.value.raw);
|
|
61
113
|
}
|
|
62
114
|
return false;
|
|
63
115
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { allowedPseudos, legacyPseudoElements } from './constants';
|
|
2
1
|
import { isNesting } from 'postcss-selector-parser';
|
|
2
|
+
import { allowedPseudos, legacyPseudoElements } from './constants';
|
|
3
3
|
import { getRangeFromNode, getSourceLocationFromRange } from './source-position-utils';
|
|
4
4
|
export function lintSelector(args) {
|
|
5
5
|
checkNoAmbiguousPseudos(args);
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
2
|
+
import { CSS_IN_JS_IMPORTS, isCssMap } from '@atlaskit/eslint-utils/is-supported-import';
|
|
3
|
+
import { createLintRule } from '../utils/create-rule';
|
|
4
|
+
const IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.atlaskitCss];
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Gets the key name from a property node
|
|
8
|
+
*/
|
|
9
|
+
function getPropertyKeyName(property) {
|
|
10
|
+
if (property.key.type === 'Identifier') {
|
|
11
|
+
return property.key.name;
|
|
12
|
+
}
|
|
13
|
+
if (property.key.type === 'Literal' && typeof property.key.value === 'string') {
|
|
14
|
+
return property.key.value;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Checks if a variable is exported from the module
|
|
21
|
+
*/
|
|
22
|
+
function isExported(node, context) {
|
|
23
|
+
let parent = node.parent;
|
|
24
|
+
|
|
25
|
+
// Walk up to find VariableDeclaration
|
|
26
|
+
while (parent && parent.type !== 'VariableDeclaration') {
|
|
27
|
+
parent = parent.parent;
|
|
28
|
+
}
|
|
29
|
+
if (!parent) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Check if the VariableDeclaration is an ExportNamedDeclaration
|
|
34
|
+
const grandParent = parent.parent;
|
|
35
|
+
if (grandParent && grandParent.type === 'ExportNamedDeclaration') {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Check if the variable is exported elsewhere in the file via `export { styles }`
|
|
40
|
+
if (node.id.type === 'Identifier') {
|
|
41
|
+
const scope = getScope(context, node);
|
|
42
|
+
const variableName = node.id.name;
|
|
43
|
+
const variable = scope.variables.find(v => v.name === variableName);
|
|
44
|
+
if (variable) {
|
|
45
|
+
// Check if any reference is a direct export specifier (e.g., `export { styles }`)
|
|
46
|
+
return variable.references.some(ref => {
|
|
47
|
+
const refParent = ref.identifier.parent;
|
|
48
|
+
// Check for direct export: `export { styles }` or `export { styles as something }`
|
|
49
|
+
// In this case, the identifier's parent is an ExportSpecifier
|
|
50
|
+
if (refParent && refParent.type === 'ExportSpecifier') {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
// Check for default export: `export default styles`
|
|
54
|
+
if (refParent && refParent.type === 'ExportDefaultDeclaration') {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
export const rule = createLintRule({
|
|
64
|
+
meta: {
|
|
65
|
+
name: 'no-unused-cssmap-properties',
|
|
66
|
+
docs: {
|
|
67
|
+
description: 'Detects unused properties in cssMap style objects that are not exported. Helps maintain clean code by identifying style variants that are defined but never used.',
|
|
68
|
+
recommended: true,
|
|
69
|
+
severity: 'warn'
|
|
70
|
+
},
|
|
71
|
+
messages: {
|
|
72
|
+
'unused-property': 'The "{{propertyName}}" style is defined but never used.'
|
|
73
|
+
},
|
|
74
|
+
type: 'problem'
|
|
75
|
+
},
|
|
76
|
+
create(context) {
|
|
77
|
+
return {
|
|
78
|
+
VariableDeclarator(node) {
|
|
79
|
+
var _getSourceCode$scopeM;
|
|
80
|
+
if (node.type !== 'VariableDeclarator') {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Only process if the initializer is a cssMap call
|
|
85
|
+
if (!node.init || node.init.type !== 'CallExpression' || !isCssMap(node.init.callee, getScope(context, node).references, IMPORT_SOURCES)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Skip if the cssMap is exported
|
|
90
|
+
if (isExported(node, context)) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Get the cssMap argument (should be an object expression)
|
|
95
|
+
const cssMapArg = node.init.arguments[0];
|
|
96
|
+
if (!cssMapArg || cssMapArg.type !== 'ObjectExpression') {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Get the variable name
|
|
101
|
+
if (node.id.type !== 'Identifier') {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const variableName = node.id.name;
|
|
105
|
+
|
|
106
|
+
// Use getDeclaredVariables to get the variable with all its references
|
|
107
|
+
// across all scopes (including nested function components)
|
|
108
|
+
const declaredVariables = (_getSourceCode$scopeM = getSourceCode(context).scopeManager) === null || _getSourceCode$scopeM === void 0 ? void 0 : _getSourceCode$scopeM.getDeclaredVariables(node);
|
|
109
|
+
const variable = declaredVariables === null || declaredVariables === void 0 ? void 0 : declaredVariables.find(v => v.name === variableName);
|
|
110
|
+
if (!variable) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Track which properties are defined
|
|
115
|
+
const definedProperties = new Set();
|
|
116
|
+
cssMapArg.properties.forEach(prop => {
|
|
117
|
+
if (prop.type === 'Property') {
|
|
118
|
+
const keyName = getPropertyKeyName(prop);
|
|
119
|
+
if (keyName) {
|
|
120
|
+
definedProperties.add(keyName);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Track which properties are used
|
|
126
|
+
const usedProperties = new Set();
|
|
127
|
+
let hasNonPropertyAccess = false;
|
|
128
|
+
variable.references.forEach(reference => {
|
|
129
|
+
// Skip the declaration itself
|
|
130
|
+
if (reference.init) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const identifier = reference.identifier;
|
|
134
|
+
const parent = identifier.parent;
|
|
135
|
+
|
|
136
|
+
// Check if it's a member access (e.g., styles.root)
|
|
137
|
+
if (parent && parent.type === 'MemberExpression' && parent.object === identifier) {
|
|
138
|
+
// Check if it's computed (dynamic) property access like styles[dynamicKey]
|
|
139
|
+
if (parent.computed) {
|
|
140
|
+
// Dynamic access - we can't determine which properties are used
|
|
141
|
+
hasNonPropertyAccess = true;
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Static property access
|
|
146
|
+
if (parent.property.type === 'Identifier') {
|
|
147
|
+
usedProperties.add(parent.property.name);
|
|
148
|
+
} else if (parent.property.type === 'Literal' && typeof parent.property.value === 'string') {
|
|
149
|
+
usedProperties.add(parent.property.value);
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
// The cssMap object is used as a whole (e.g., spread, passed to function, etc.)
|
|
153
|
+
// In this case, we can't determine which properties are used, so mark all as used
|
|
154
|
+
hasNonPropertyAccess = true;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// If the object is used as a whole (not just property access), skip checks
|
|
159
|
+
if (hasNonPropertyAccess) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Report unused properties
|
|
164
|
+
cssMapArg.properties.forEach(prop => {
|
|
165
|
+
if (prop.type === 'Property') {
|
|
166
|
+
const keyName = getPropertyKeyName(prop);
|
|
167
|
+
if (keyName && !usedProperties.has(keyName)) {
|
|
168
|
+
context.report({
|
|
169
|
+
node: prop.key,
|
|
170
|
+
messageId: 'unused-property',
|
|
171
|
+
data: {
|
|
172
|
+
propertyName: keyName
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
export default rule;
|
|
@@ -3,9 +3,10 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
/**
|
|
5
5
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::93c84481278f52fc66ecbba80094e6e5>>
|
|
7
7
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
8
8
|
*/
|
|
9
|
+
|
|
9
10
|
import allFlat from './presets/all-flat.codegen';
|
|
10
11
|
import all from './presets/all.codegen';
|
|
11
12
|
import recommendedFlat from './presets/recommended-flat.codegen';
|
|
@@ -46,7 +47,6 @@ export var plugin = {
|
|
|
46
47
|
}
|
|
47
48
|
};
|
|
48
49
|
export { rules } from './rules/index.codegen';
|
|
49
|
-
var configs = plugin.configs
|
|
50
|
-
|
|
51
|
-
export { configs, meta };
|
|
50
|
+
export var configs = plugin.configs;
|
|
51
|
+
export var meta = plugin.meta;
|
|
52
52
|
export default plugin;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::f99588f71d6b353cefbed97fd172e433>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
|
+
|
|
6
7
|
import * as atlaskitDesignSystemPlugin from '@atlaskit/eslint-plugin-design-system';
|
|
7
|
-
|
|
8
|
+
var config = {
|
|
8
9
|
plugins: {
|
|
9
10
|
// NOTE: The reference to this plugin is inserted dynamically while creating the plugin in `index.codegen.tsx`
|
|
10
11
|
'@atlaskit/design-system': atlaskitDesignSystemPlugin
|
|
@@ -26,6 +27,7 @@ export default {
|
|
|
26
27
|
'@atlaskit/ui-styling-standard/no-styled': 'error',
|
|
27
28
|
'@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
|
|
28
29
|
'@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
|
|
30
|
+
'@atlaskit/ui-styling-standard/no-unused-cssmap-properties': 'warn',
|
|
29
31
|
'@atlaskit/ui-styling-standard/use-compiled': 'error',
|
|
30
32
|
'@atlaskit/design-system/consistent-css-prop-usage': ['error', {
|
|
31
33
|
excludeReactComponents: true,
|
|
@@ -41,4 +43,5 @@ export default {
|
|
|
41
43
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
42
44
|
}]
|
|
43
45
|
}
|
|
44
|
-
};
|
|
46
|
+
};
|
|
47
|
+
export default config;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::8f28dfef84548edbe33f59201f295cc5>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
var config = {
|
|
7
8
|
plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system'],
|
|
8
9
|
rules: {
|
|
9
10
|
'@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
|
|
@@ -22,6 +23,7 @@ export default {
|
|
|
22
23
|
'@atlaskit/ui-styling-standard/no-styled': 'error',
|
|
23
24
|
'@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
|
|
24
25
|
'@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
|
|
26
|
+
'@atlaskit/ui-styling-standard/no-unused-cssmap-properties': 'warn',
|
|
25
27
|
'@atlaskit/ui-styling-standard/use-compiled': 'error',
|
|
26
28
|
'@atlaskit/design-system/consistent-css-prop-usage': ['error', {
|
|
27
29
|
excludeReactComponents: true,
|
|
@@ -37,4 +39,5 @@ export default {
|
|
|
37
39
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
38
40
|
}]
|
|
39
41
|
}
|
|
40
|
-
};
|
|
42
|
+
};
|
|
43
|
+
export default config;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::f99588f71d6b353cefbed97fd172e433>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
|
+
|
|
6
7
|
import * as atlaskitDesignSystemPlugin from '@atlaskit/eslint-plugin-design-system';
|
|
7
|
-
|
|
8
|
+
var config = {
|
|
8
9
|
plugins: {
|
|
9
10
|
// NOTE: The reference to this plugin is inserted dynamically while creating the plugin in `index.codegen.tsx`
|
|
10
11
|
'@atlaskit/design-system': atlaskitDesignSystemPlugin
|
|
@@ -26,6 +27,7 @@ export default {
|
|
|
26
27
|
'@atlaskit/ui-styling-standard/no-styled': 'error',
|
|
27
28
|
'@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
|
|
28
29
|
'@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
|
|
30
|
+
'@atlaskit/ui-styling-standard/no-unused-cssmap-properties': 'warn',
|
|
29
31
|
'@atlaskit/ui-styling-standard/use-compiled': 'error',
|
|
30
32
|
'@atlaskit/design-system/consistent-css-prop-usage': ['error', {
|
|
31
33
|
excludeReactComponents: true,
|
|
@@ -41,4 +43,5 @@ export default {
|
|
|
41
43
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
42
44
|
}]
|
|
43
45
|
}
|
|
44
|
-
};
|
|
46
|
+
};
|
|
47
|
+
export default config;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::8f28dfef84548edbe33f59201f295cc5>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
var config = {
|
|
7
8
|
plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system'],
|
|
8
9
|
rules: {
|
|
9
10
|
'@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
|
|
@@ -22,6 +23,7 @@ export default {
|
|
|
22
23
|
'@atlaskit/ui-styling-standard/no-styled': 'error',
|
|
23
24
|
'@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
|
|
24
25
|
'@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
|
|
26
|
+
'@atlaskit/ui-styling-standard/no-unused-cssmap-properties': 'warn',
|
|
25
27
|
'@atlaskit/ui-styling-standard/use-compiled': 'error',
|
|
26
28
|
'@atlaskit/design-system/consistent-css-prop-usage': ['error', {
|
|
27
29
|
excludeReactComponents: true,
|
|
@@ -37,4 +39,5 @@ export default {
|
|
|
37
39
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
38
40
|
}]
|
|
39
41
|
}
|
|
40
|
-
};
|
|
42
|
+
};
|
|
43
|
+
export default config;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::2eab912b0c44d0fcbdc2f0b79cb42fa9>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
|
+
|
|
6
7
|
import atlaskitTheme from './atlaskit-theme';
|
|
7
8
|
import convertPropsSyntax from './convert-props-syntax';
|
|
8
9
|
import enforceStyleProp from './enforce-style-prop';
|
|
@@ -19,6 +20,7 @@ import noNestedSelectors from './no-nested-selectors';
|
|
|
19
20
|
import noStyled from './no-styled';
|
|
20
21
|
import noUnsafeSelectors from './no-unsafe-selectors';
|
|
21
22
|
import noUnsafeValues from './no-unsafe-values';
|
|
23
|
+
import noUnusedCssmapProperties from './no-unused-cssmap-properties';
|
|
22
24
|
import useCompiled from './use-compiled';
|
|
23
25
|
export var rules = {
|
|
24
26
|
'atlaskit-theme': atlaskitTheme,
|
|
@@ -37,5 +39,6 @@ export var rules = {
|
|
|
37
39
|
'no-styled': noStyled,
|
|
38
40
|
'no-unsafe-selectors': noUnsafeSelectors,
|
|
39
41
|
'no-unsafe-values': noUnsafeValues,
|
|
42
|
+
'no-unused-cssmap-properties': noUnusedCssmapProperties,
|
|
40
43
|
'use-compiled': useCompiled
|
|
41
44
|
};
|