@atlaskit/eslint-plugin-design-system 10.22.1 → 10.23.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 +11 -0
- package/README.md +1 -0
- package/dist/cjs/index.codegen.js +44 -10
- package/dist/cjs/index.js +29 -2
- package/dist/cjs/presets/all-flat.codegen.js +61 -0
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/presets/recommended-flat.codegen.js +45 -0
- package/dist/cjs/presets/recommended.codegen.js +2 -1
- package/dist/cjs/rules/index.codegen.js +6 -3
- package/dist/cjs/rules/no-separator-with-list-elements/index.js +62 -0
- package/dist/es2019/index.codegen.js +46 -6
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/presets/all-flat.codegen.js +55 -0
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/presets/recommended-flat.codegen.js +39 -0
- package/dist/es2019/presets/recommended.codegen.js +2 -1
- package/dist/es2019/rules/index.codegen.js +4 -2
- package/dist/es2019/rules/no-separator-with-list-elements/index.js +50 -0
- package/dist/esm/index.codegen.js +44 -6
- package/dist/esm/index.js +1 -1
- package/dist/esm/presets/all-flat.codegen.js +55 -0
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/presets/recommended-flat.codegen.js +39 -0
- package/dist/esm/presets/recommended.codegen.js +2 -1
- package/dist/esm/rules/index.codegen.js +4 -2
- package/dist/esm/rules/no-separator-with-list-elements/index.js +56 -0
- package/dist/types/index.codegen.d.ts +508 -77
- package/dist/types/index.d.ts +1 -1
- package/dist/types/presets/all-flat.codegen.d.ts +55 -0
- package/dist/types/presets/all.codegen.d.ts +47 -46
- package/dist/types/presets/recommended-flat.codegen.d.ts +39 -0
- package/dist/types/presets/recommended.codegen.d.ts +31 -30
- package/dist/types/rules/index.codegen.d.ts +2 -2
- package/dist/types/rules/no-separator-with-list-elements/index.d.ts +3 -0
- package/dist/types-ts4.5/index.codegen.d.ts +592 -77
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +63 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +57 -46
- package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +47 -0
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +41 -30
- package/dist/types-ts4.5/rules/index.codegen.d.ts +2 -2
- package/dist/types-ts4.5/rules/no-separator-with-list-elements/index.d.ts +3 -0
- package/package.json +4 -2
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
import { createLintRule } from '../utils/create-rule';
|
|
3
|
+
const separatorAsCombinationNotAllowed = 'The combination of `separator` with `as="li"`, `as="ol"`, or `as="dl"` is not allowed.';
|
|
4
|
+
const rule = createLintRule({
|
|
5
|
+
meta: {
|
|
6
|
+
name: 'no-separator-with-list-elements',
|
|
7
|
+
type: 'suggestion',
|
|
8
|
+
docs: {
|
|
9
|
+
description: 'Warn when the `separator` prop is used with `as="li"`, `as="ol"`, or `as="dl"` in the Inline component.',
|
|
10
|
+
recommended: true,
|
|
11
|
+
severity: 'warn'
|
|
12
|
+
},
|
|
13
|
+
messages: {
|
|
14
|
+
separatorAsCombinationNotAllowed
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
create(context) {
|
|
18
|
+
const inlineComponentNames = [];
|
|
19
|
+
return {
|
|
20
|
+
ImportDeclaration(node) {
|
|
21
|
+
if (node.type === 'ImportDeclaration' && (node.source.value === '../src' || node.source.value === '@atlaskit/primitives')) {
|
|
22
|
+
node.specifiers.forEach(specifier => {
|
|
23
|
+
if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'Inline') {
|
|
24
|
+
inlineComponentNames.push(specifier.local.name);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
JSXElement(node) {
|
|
30
|
+
if (!isNodeOfType(node, 'JSXElement') || !isNodeOfType(node.openingElement.name, 'JSXIdentifier')) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const componentName = node.openingElement.name.name;
|
|
34
|
+
if (!inlineComponentNames.includes(componentName)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const inlineProps = node.openingElement.attributes.filter(attr => isNodeOfType(attr, 'JSXAttribute') && isNodeOfType(attr.name, 'JSXIdentifier'));
|
|
38
|
+
const separatorProp = inlineProps.find(attr => attr.name.name === 'separator');
|
|
39
|
+
const asProp = inlineProps.find(attr => attr.name.name === 'as');
|
|
40
|
+
if (separatorProp && asProp && asProp.value && isNodeOfType(asProp.value, 'Literal') && ['li', 'ol', 'dl'].includes(asProp.value.value)) {
|
|
41
|
+
context.report({
|
|
42
|
+
node: node,
|
|
43
|
+
messageId: 'separatorAsCombinationNotAllowed'
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
export default rule;
|
|
@@ -1,12 +1,50 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
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; }
|
|
1
4
|
/**
|
|
2
5
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::7656123b732a9145dedb7f9eee588883>>
|
|
4
7
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
8
|
*/
|
|
9
|
+
import allFlat from './presets/all-flat.codegen';
|
|
6
10
|
import all from './presets/all.codegen';
|
|
11
|
+
import recommendedFlat from './presets/recommended-flat.codegen';
|
|
7
12
|
import recommended from './presets/recommended.codegen';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
import { rules } from './rules/index.codegen';
|
|
14
|
+
|
|
15
|
+
// this uses require because not all node versions this package supports use the same import assertions/attributes
|
|
16
|
+
var pkgJson = require('../package.json');
|
|
17
|
+
var version = pkgJson.version,
|
|
18
|
+
name = pkgJson.name;
|
|
19
|
+
export { version, name };
|
|
20
|
+
export var plugin = {
|
|
21
|
+
meta: {
|
|
22
|
+
name: name,
|
|
23
|
+
version: version
|
|
24
|
+
},
|
|
25
|
+
rules: rules,
|
|
26
|
+
// flat configs need to be done like this so they can get a reference to the plugin.
|
|
27
|
+
// see here: https://eslint.org/docs/latest/extend/plugins#configs-in-plugins
|
|
28
|
+
// they cannot use `Object.assign` because it will not work with the getter
|
|
29
|
+
configs: {
|
|
30
|
+
all: all,
|
|
31
|
+
'all/flat': _objectSpread(_objectSpread({}, allFlat), {}, {
|
|
32
|
+
plugins: _objectSpread(_objectSpread({}, allFlat.plugins), {}, {
|
|
33
|
+
get '@atlaskit/design-system'() {
|
|
34
|
+
return plugin;
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
}),
|
|
38
|
+
recommended: recommended,
|
|
39
|
+
'recommended/flat': _objectSpread(_objectSpread({}, recommendedFlat), {}, {
|
|
40
|
+
plugins: _objectSpread(_objectSpread({}, recommendedFlat.plugins), {}, {
|
|
41
|
+
get '@atlaskit/design-system'() {
|
|
42
|
+
return plugin;
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
export { rules } from './rules/index.codegen';
|
|
49
|
+
export var configs = plugin.configs;
|
|
50
|
+
export default plugin;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { version, name, rules, plugin, configs, default } from './index.codegen';
|
|
2
2
|
export { filterActionableDeprecations } from './rules/no-deprecated-apis/helpers/filter-actionable-deprecations';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
* @codegen <<SignedSource::56a9d309ec6f548dce4a4f6e99059a15>>
|
|
4
|
+
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
|
+
*/
|
|
6
|
+
export default {
|
|
7
|
+
// NOTE: The reference to this plugin is inserted dynamically while creating the plugin in `index.codegen.tsx`
|
|
8
|
+
plugins: {},
|
|
9
|
+
rules: {
|
|
10
|
+
'@atlaskit/design-system/consistent-css-prop-usage': 'error',
|
|
11
|
+
'@atlaskit/design-system/ensure-design-token-usage': 'error',
|
|
12
|
+
'@atlaskit/design-system/ensure-design-token-usage/preview': 'warn',
|
|
13
|
+
'@atlaskit/design-system/ensure-icon-color': 'error',
|
|
14
|
+
'@atlaskit/design-system/icon-label': 'warn',
|
|
15
|
+
'@atlaskit/design-system/no-banned-imports': 'error',
|
|
16
|
+
'@atlaskit/design-system/no-css-tagged-template-expression': 'error',
|
|
17
|
+
'@atlaskit/design-system/no-custom-icons': 'warn',
|
|
18
|
+
'@atlaskit/design-system/no-dark-theme-vr-tests': 'error',
|
|
19
|
+
'@atlaskit/design-system/no-deprecated-apis': 'error',
|
|
20
|
+
'@atlaskit/design-system/no-deprecated-design-token-usage': 'warn',
|
|
21
|
+
'@atlaskit/design-system/no-deprecated-imports': 'error',
|
|
22
|
+
'@atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop': 'error',
|
|
23
|
+
'@atlaskit/design-system/no-html-anchor': 'warn',
|
|
24
|
+
'@atlaskit/design-system/no-html-button': 'warn',
|
|
25
|
+
'@atlaskit/design-system/no-invalid-css-map': ['error', {
|
|
26
|
+
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
27
|
+
}],
|
|
28
|
+
'@atlaskit/design-system/no-keyframes-tagged-template-expression': 'error',
|
|
29
|
+
'@atlaskit/design-system/no-legacy-icons': 'warn',
|
|
30
|
+
'@atlaskit/design-system/no-margin': 'warn',
|
|
31
|
+
'@atlaskit/design-system/no-nested-styles': 'error',
|
|
32
|
+
'@atlaskit/design-system/no-physical-properties': 'error',
|
|
33
|
+
'@atlaskit/design-system/no-separator-with-list-elements': 'warn',
|
|
34
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': 'error',
|
|
35
|
+
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
36
|
+
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
37
|
+
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
38
|
+
'@atlaskit/design-system/prefer-primitives': 'warn',
|
|
39
|
+
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
40
|
+
'@atlaskit/design-system/use-drawer-label': 'warn',
|
|
41
|
+
'@atlaskit/design-system/use-heading': 'warn',
|
|
42
|
+
'@atlaskit/design-system/use-heading-level-in-spotlight-card': 'warn',
|
|
43
|
+
'@atlaskit/design-system/use-href-in-link-item': 'warn',
|
|
44
|
+
'@atlaskit/design-system/use-latest-xcss-syntax': 'error',
|
|
45
|
+
'@atlaskit/design-system/use-latest-xcss-syntax-typography': 'warn',
|
|
46
|
+
'@atlaskit/design-system/use-menu-section-title': 'warn',
|
|
47
|
+
'@atlaskit/design-system/use-popup-label': 'warn',
|
|
48
|
+
'@atlaskit/design-system/use-primitives': 'warn',
|
|
49
|
+
'@atlaskit/design-system/use-primitives-text': 'warn',
|
|
50
|
+
'@atlaskit/design-system/use-tag-group-label': 'warn',
|
|
51
|
+
'@atlaskit/design-system/use-tokens-space': 'error',
|
|
52
|
+
'@atlaskit/design-system/use-tokens-typography': 'warn',
|
|
53
|
+
'@atlaskit/design-system/use-visually-hidden': 'error'
|
|
54
|
+
}
|
|
55
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::47f018ad98455be31dc522bcf5360adf>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -29,6 +29,7 @@ export default {
|
|
|
29
29
|
'@atlaskit/design-system/no-margin': 'warn',
|
|
30
30
|
'@atlaskit/design-system/no-nested-styles': 'error',
|
|
31
31
|
'@atlaskit/design-system/no-physical-properties': 'error',
|
|
32
|
+
'@atlaskit/design-system/no-separator-with-list-elements': 'warn',
|
|
32
33
|
'@atlaskit/design-system/no-styled-tagged-template-expression': 'error',
|
|
33
34
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
34
35
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
+
* @codegen <<SignedSource::9c6dda34a88386c4fa5b931ab4baf929>>
|
|
4
|
+
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
|
+
*/
|
|
6
|
+
export default {
|
|
7
|
+
// NOTE: The reference to this plugin is inserted dynamically while creating the plugin in `index.codegen.tsx`
|
|
8
|
+
plugins: {},
|
|
9
|
+
rules: {
|
|
10
|
+
'@atlaskit/design-system/consistent-css-prop-usage': 'error',
|
|
11
|
+
'@atlaskit/design-system/ensure-design-token-usage': 'error',
|
|
12
|
+
'@atlaskit/design-system/icon-label': 'warn',
|
|
13
|
+
'@atlaskit/design-system/no-banned-imports': 'error',
|
|
14
|
+
'@atlaskit/design-system/no-deprecated-apis': 'error',
|
|
15
|
+
'@atlaskit/design-system/no-deprecated-design-token-usage': 'warn',
|
|
16
|
+
'@atlaskit/design-system/no-deprecated-imports': 'error',
|
|
17
|
+
'@atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop': 'error',
|
|
18
|
+
'@atlaskit/design-system/no-html-anchor': 'warn',
|
|
19
|
+
'@atlaskit/design-system/no-html-button': 'warn',
|
|
20
|
+
'@atlaskit/design-system/no-invalid-css-map': ['error', {
|
|
21
|
+
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
22
|
+
}],
|
|
23
|
+
'@atlaskit/design-system/no-nested-styles': 'error',
|
|
24
|
+
'@atlaskit/design-system/no-separator-with-list-elements': 'warn',
|
|
25
|
+
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
26
|
+
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
27
|
+
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
28
|
+
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
29
|
+
'@atlaskit/design-system/use-drawer-label': 'warn',
|
|
30
|
+
'@atlaskit/design-system/use-heading-level-in-spotlight-card': 'warn',
|
|
31
|
+
'@atlaskit/design-system/use-href-in-link-item': 'warn',
|
|
32
|
+
'@atlaskit/design-system/use-latest-xcss-syntax': 'error',
|
|
33
|
+
'@atlaskit/design-system/use-latest-xcss-syntax-typography': 'warn',
|
|
34
|
+
'@atlaskit/design-system/use-menu-section-title': 'warn',
|
|
35
|
+
'@atlaskit/design-system/use-popup-label': 'warn',
|
|
36
|
+
'@atlaskit/design-system/use-tag-group-label': 'warn',
|
|
37
|
+
'@atlaskit/design-system/use-visually-hidden': 'error'
|
|
38
|
+
}
|
|
39
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::f1b4aa9e656294739485e62ba4a33f9d>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -20,6 +20,7 @@ export default {
|
|
|
20
20
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
21
21
|
}],
|
|
22
22
|
'@atlaskit/design-system/no-nested-styles': 'error',
|
|
23
|
+
'@atlaskit/design-system/no-separator-with-list-elements': 'warn',
|
|
23
24
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
24
25
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
25
26
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::2ab06b34c4e08cd70b0f67f5915f12c9>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import consistentCssPropUsage from './consistent-css-prop-usage';
|
|
@@ -27,6 +27,7 @@ import noLegacyIcons from './no-legacy-icons';
|
|
|
27
27
|
import noMargin from './no-margin';
|
|
28
28
|
import noNestedStyles from './no-nested-styles';
|
|
29
29
|
import noPhysicalProperties from './no-physical-properties';
|
|
30
|
+
import noSeparatorWithListElements from './no-separator-with-list-elements';
|
|
30
31
|
import noStyledTaggedTemplateExpression from './no-styled-tagged-template-expression';
|
|
31
32
|
import noUnsafeDesignTokenUsage from './no-unsafe-design-token-usage';
|
|
32
33
|
import noUnsafeStyleOverrides from './no-unsafe-style-overrides';
|
|
@@ -47,7 +48,7 @@ import useTagGroupLabel from './use-tag-group-label';
|
|
|
47
48
|
import useTokensSpace from './use-tokens-space';
|
|
48
49
|
import useTokensTypography from './use-tokens-typography';
|
|
49
50
|
import useVisuallyHidden from './use-visually-hidden';
|
|
50
|
-
export
|
|
51
|
+
export var rules = {
|
|
51
52
|
'consistent-css-prop-usage': consistentCssPropUsage,
|
|
52
53
|
'ensure-design-token-usage': ensureDesignTokenUsage,
|
|
53
54
|
'ensure-design-token-usage/preview': ensureDesignTokenUsagePreview,
|
|
@@ -72,6 +73,7 @@ export default {
|
|
|
72
73
|
'no-margin': noMargin,
|
|
73
74
|
'no-nested-styles': noNestedStyles,
|
|
74
75
|
'no-physical-properties': noPhysicalProperties,
|
|
76
|
+
'no-separator-with-list-elements': noSeparatorWithListElements,
|
|
75
77
|
'no-styled-tagged-template-expression': noStyledTaggedTemplateExpression,
|
|
76
78
|
'no-unsafe-design-token-usage': noUnsafeDesignTokenUsage,
|
|
77
79
|
'no-unsafe-style-overrides': noUnsafeStyleOverrides,
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
import { createLintRule } from '../utils/create-rule';
|
|
3
|
+
var separatorAsCombinationNotAllowed = 'The combination of `separator` with `as="li"`, `as="ol"`, or `as="dl"` is not allowed.';
|
|
4
|
+
var rule = createLintRule({
|
|
5
|
+
meta: {
|
|
6
|
+
name: 'no-separator-with-list-elements',
|
|
7
|
+
type: 'suggestion',
|
|
8
|
+
docs: {
|
|
9
|
+
description: 'Warn when the `separator` prop is used with `as="li"`, `as="ol"`, or `as="dl"` in the Inline component.',
|
|
10
|
+
recommended: true,
|
|
11
|
+
severity: 'warn'
|
|
12
|
+
},
|
|
13
|
+
messages: {
|
|
14
|
+
separatorAsCombinationNotAllowed: separatorAsCombinationNotAllowed
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
create: function create(context) {
|
|
18
|
+
var inlineComponentNames = [];
|
|
19
|
+
return {
|
|
20
|
+
ImportDeclaration: function ImportDeclaration(node) {
|
|
21
|
+
if (node.type === 'ImportDeclaration' && (node.source.value === '../src' || node.source.value === '@atlaskit/primitives')) {
|
|
22
|
+
node.specifiers.forEach(function (specifier) {
|
|
23
|
+
if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'Inline') {
|
|
24
|
+
inlineComponentNames.push(specifier.local.name);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
JSXElement: function JSXElement(node) {
|
|
30
|
+
if (!isNodeOfType(node, 'JSXElement') || !isNodeOfType(node.openingElement.name, 'JSXIdentifier')) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
var componentName = node.openingElement.name.name;
|
|
34
|
+
if (!inlineComponentNames.includes(componentName)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
var inlineProps = node.openingElement.attributes.filter(function (attr) {
|
|
38
|
+
return isNodeOfType(attr, 'JSXAttribute') && isNodeOfType(attr.name, 'JSXIdentifier');
|
|
39
|
+
});
|
|
40
|
+
var separatorProp = inlineProps.find(function (attr) {
|
|
41
|
+
return attr.name.name === 'separator';
|
|
42
|
+
});
|
|
43
|
+
var asProp = inlineProps.find(function (attr) {
|
|
44
|
+
return attr.name.name === 'as';
|
|
45
|
+
});
|
|
46
|
+
if (separatorProp && asProp && asProp.value && isNodeOfType(asProp.value, 'Literal') && ['li', 'ol', 'dl'].includes(asProp.value.value)) {
|
|
47
|
+
context.report({
|
|
48
|
+
node: node,
|
|
49
|
+
messageId: 'separatorAsCombinationNotAllowed'
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
export default rule;
|