@atlaskit/eslint-plugin-platform 0.1.4 → 0.1.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 +6 -0
- package/dist/cjs/index.js +5 -2
- package/dist/cjs/rules/no-invalid-storybook-decorator-usage/index.js +38 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/index.js +5 -2
- package/dist/es2019/rules/no-invalid-storybook-decorator-usage/index.js +31 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/index.js +5 -2
- package/dist/esm/rules/no-invalid-storybook-decorator-usage/index.js +30 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/rules/no-invalid-storybook-decorator-usage/index.d.ts +3 -0
- package/package.json +1 -1
- package/report.api.md +2 -0
- package/src/index.tsx +3 -0
- package/src/rules/no-invalid-storybook-decorator-usage/__tests__/unit/rule.test.tsx +18 -0
- package/src/rules/no-invalid-storybook-decorator-usage/index.tsx +40 -0
- package/tmp/api-report-tmp.d.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-platform
|
|
2
2
|
|
|
3
|
+
## 0.1.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`b47e48ad163`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b47e48ad163) - Adds an eslint rule to confirm that storybooks only get passed an object - to ensure that codemods work correctly.
|
|
8
|
+
|
|
3
9
|
## 0.1.4
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -10,12 +10,14 @@ var _noPrePostInstalls = _interopRequireDefault(require("./rules/no-pre-post-ins
|
|
|
10
10
|
var _ensureTestRunnerArguments = _interopRequireDefault(require("./rules/ensure-test-runner-arguments"));
|
|
11
11
|
var _ensureTestRunnerNestedCount = _interopRequireDefault(require("./rules/ensure-test-runner-nested-count"));
|
|
12
12
|
var _noInvalidFeatureFlagUsage = _interopRequireDefault(require("./rules/no-invalid-feature-flag-usage"));
|
|
13
|
+
var _noInvalidStorybookDecoratorUsage = _interopRequireDefault(require("./rules/no-invalid-storybook-decorator-usage"));
|
|
13
14
|
var rules = {
|
|
14
15
|
'ensure-feature-flag-registration': _ensureFeatureFlagRegistration.default,
|
|
15
16
|
'ensure-test-runner-arguments': _ensureTestRunnerArguments.default,
|
|
16
17
|
'ensure-test-runner-nested-count': _ensureTestRunnerNestedCount.default,
|
|
17
18
|
'no-invalid-feature-flag-usage': _noInvalidFeatureFlagUsage.default,
|
|
18
|
-
'no-pre-post-install-scripts': _noPrePostInstalls.default
|
|
19
|
+
'no-pre-post-install-scripts': _noPrePostInstalls.default,
|
|
20
|
+
'no-invalid-storybook-decorator-usage': _noInvalidStorybookDecoratorUsage.default
|
|
19
21
|
};
|
|
20
22
|
exports.rules = rules;
|
|
21
23
|
var configs = {
|
|
@@ -25,7 +27,8 @@ var configs = {
|
|
|
25
27
|
'@atlaskit/platform/ensure-feature-flag-registration': 'error',
|
|
26
28
|
'@atlaskit/platform/ensure-test-runner-arguments': 'error',
|
|
27
29
|
'@atlaskit/platform/ensure-test-runner-nested-count': 'warn',
|
|
28
|
-
'@atlaskit/platform/no-invalid-feature-flag-usage': 'error'
|
|
30
|
+
'@atlaskit/platform/no-invalid-feature-flag-usage': 'error',
|
|
31
|
+
'@atlaskit/platform/no-invalid-storybook-decorator-usage': 'error'
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var STORYBOOK_DECORATOR_IDENTIFIER = 'withPlatformFeatureFlags';
|
|
10
|
+
var rule = {
|
|
11
|
+
meta: {
|
|
12
|
+
hasSuggestions: false,
|
|
13
|
+
docs: {
|
|
14
|
+
recommended: false
|
|
15
|
+
},
|
|
16
|
+
type: 'problem',
|
|
17
|
+
messages: {
|
|
18
|
+
onlyObjectExpression: 'Only object literals allowed in the storybook decorator! See http://go/pff-eslint for more details'
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
create: function create(context) {
|
|
22
|
+
return (0, _defineProperty2.default)({}, "CallExpression[callee.name=/".concat(STORYBOOK_DECORATOR_IDENTIFIER, "/]"), function CallExpressionCalleeName(node) {
|
|
23
|
+
// to make typescript happy
|
|
24
|
+
if (node.type === 'CallExpression') {
|
|
25
|
+
var args = node.arguments;
|
|
26
|
+
if (args.length === 1 && args[0].type !== 'ObjectExpression') {
|
|
27
|
+
return context.report({
|
|
28
|
+
node: node,
|
|
29
|
+
messageId: 'onlyObjectExpression'
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return {};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var _default = rule;
|
|
38
|
+
exports.default = _default;
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/index.js
CHANGED
|
@@ -3,12 +3,14 @@ import noPreAndPostInstallScripts from './rules/no-pre-post-installs';
|
|
|
3
3
|
import ensureTestRunnerArguments from './rules/ensure-test-runner-arguments';
|
|
4
4
|
import ensureTestRunnerNestedCount from './rules/ensure-test-runner-nested-count';
|
|
5
5
|
import noInvalidFeatureFlagUsage from './rules/no-invalid-feature-flag-usage';
|
|
6
|
+
import noInvalidStorybookDecoratorUsage from './rules/no-invalid-storybook-decorator-usage';
|
|
6
7
|
export const rules = {
|
|
7
8
|
'ensure-feature-flag-registration': ensureFeatureFlagRegistration,
|
|
8
9
|
'ensure-test-runner-arguments': ensureTestRunnerArguments,
|
|
9
10
|
'ensure-test-runner-nested-count': ensureTestRunnerNestedCount,
|
|
10
11
|
'no-invalid-feature-flag-usage': noInvalidFeatureFlagUsage,
|
|
11
|
-
'no-pre-post-install-scripts': noPreAndPostInstallScripts
|
|
12
|
+
'no-pre-post-install-scripts': noPreAndPostInstallScripts,
|
|
13
|
+
'no-invalid-storybook-decorator-usage': noInvalidStorybookDecoratorUsage
|
|
12
14
|
};
|
|
13
15
|
export const configs = {
|
|
14
16
|
recommended: {
|
|
@@ -17,7 +19,8 @@ export const configs = {
|
|
|
17
19
|
'@atlaskit/platform/ensure-feature-flag-registration': 'error',
|
|
18
20
|
'@atlaskit/platform/ensure-test-runner-arguments': 'error',
|
|
19
21
|
'@atlaskit/platform/ensure-test-runner-nested-count': 'warn',
|
|
20
|
-
'@atlaskit/platform/no-invalid-feature-flag-usage': 'error'
|
|
22
|
+
'@atlaskit/platform/no-invalid-feature-flag-usage': 'error',
|
|
23
|
+
'@atlaskit/platform/no-invalid-storybook-decorator-usage': 'error'
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const STORYBOOK_DECORATOR_IDENTIFIER = 'withPlatformFeatureFlags';
|
|
2
|
+
const rule = {
|
|
3
|
+
meta: {
|
|
4
|
+
hasSuggestions: false,
|
|
5
|
+
docs: {
|
|
6
|
+
recommended: false
|
|
7
|
+
},
|
|
8
|
+
type: 'problem',
|
|
9
|
+
messages: {
|
|
10
|
+
onlyObjectExpression: 'Only object literals allowed in the storybook decorator! See http://go/pff-eslint for more details'
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
create(context) {
|
|
14
|
+
return {
|
|
15
|
+
[`CallExpression[callee.name=/${STORYBOOK_DECORATOR_IDENTIFIER}/]`]: node => {
|
|
16
|
+
// to make typescript happy
|
|
17
|
+
if (node.type === 'CallExpression') {
|
|
18
|
+
const args = node.arguments;
|
|
19
|
+
if (args.length === 1 && args[0].type !== 'ObjectExpression') {
|
|
20
|
+
return context.report({
|
|
21
|
+
node,
|
|
22
|
+
messageId: 'onlyObjectExpression'
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export default rule;
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -3,12 +3,14 @@ import noPreAndPostInstallScripts from './rules/no-pre-post-installs';
|
|
|
3
3
|
import ensureTestRunnerArguments from './rules/ensure-test-runner-arguments';
|
|
4
4
|
import ensureTestRunnerNestedCount from './rules/ensure-test-runner-nested-count';
|
|
5
5
|
import noInvalidFeatureFlagUsage from './rules/no-invalid-feature-flag-usage';
|
|
6
|
+
import noInvalidStorybookDecoratorUsage from './rules/no-invalid-storybook-decorator-usage';
|
|
6
7
|
export var rules = {
|
|
7
8
|
'ensure-feature-flag-registration': ensureFeatureFlagRegistration,
|
|
8
9
|
'ensure-test-runner-arguments': ensureTestRunnerArguments,
|
|
9
10
|
'ensure-test-runner-nested-count': ensureTestRunnerNestedCount,
|
|
10
11
|
'no-invalid-feature-flag-usage': noInvalidFeatureFlagUsage,
|
|
11
|
-
'no-pre-post-install-scripts': noPreAndPostInstallScripts
|
|
12
|
+
'no-pre-post-install-scripts': noPreAndPostInstallScripts,
|
|
13
|
+
'no-invalid-storybook-decorator-usage': noInvalidStorybookDecoratorUsage
|
|
12
14
|
};
|
|
13
15
|
export var configs = {
|
|
14
16
|
recommended: {
|
|
@@ -17,7 +19,8 @@ export var configs = {
|
|
|
17
19
|
'@atlaskit/platform/ensure-feature-flag-registration': 'error',
|
|
18
20
|
'@atlaskit/platform/ensure-test-runner-arguments': 'error',
|
|
19
21
|
'@atlaskit/platform/ensure-test-runner-nested-count': 'warn',
|
|
20
|
-
'@atlaskit/platform/no-invalid-feature-flag-usage': 'error'
|
|
22
|
+
'@atlaskit/platform/no-invalid-feature-flag-usage': 'error',
|
|
23
|
+
'@atlaskit/platform/no-invalid-storybook-decorator-usage': 'error'
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
var STORYBOOK_DECORATOR_IDENTIFIER = 'withPlatformFeatureFlags';
|
|
3
|
+
var rule = {
|
|
4
|
+
meta: {
|
|
5
|
+
hasSuggestions: false,
|
|
6
|
+
docs: {
|
|
7
|
+
recommended: false
|
|
8
|
+
},
|
|
9
|
+
type: 'problem',
|
|
10
|
+
messages: {
|
|
11
|
+
onlyObjectExpression: 'Only object literals allowed in the storybook decorator! See http://go/pff-eslint for more details'
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
create: function create(context) {
|
|
15
|
+
return _defineProperty({}, "CallExpression[callee.name=/".concat(STORYBOOK_DECORATOR_IDENTIFIER, "/]"), function CallExpressionCalleeName(node) {
|
|
16
|
+
// to make typescript happy
|
|
17
|
+
if (node.type === 'CallExpression') {
|
|
18
|
+
var args = node.arguments;
|
|
19
|
+
if (args.length === 1 && args[0].type !== 'ObjectExpression') {
|
|
20
|
+
return context.report({
|
|
21
|
+
node: node,
|
|
22
|
+
messageId: 'onlyObjectExpression'
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return {};
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export default rule;
|
package/dist/esm/version.json
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const rules: {
|
|
|
5
5
|
'ensure-test-runner-nested-count': import("eslint").Rule.RuleModule;
|
|
6
6
|
'no-invalid-feature-flag-usage': import("eslint").Rule.RuleModule;
|
|
7
7
|
'no-pre-post-install-scripts': import("eslint").Rule.RuleModule;
|
|
8
|
+
'no-invalid-storybook-decorator-usage': import("eslint").Rule.RuleModule;
|
|
8
9
|
};
|
|
9
10
|
export declare const configs: {
|
|
10
11
|
recommended: {
|
|
@@ -14,6 +15,7 @@ export declare const configs: {
|
|
|
14
15
|
'@atlaskit/platform/ensure-test-runner-arguments': string;
|
|
15
16
|
'@atlaskit/platform/ensure-test-runner-nested-count': string;
|
|
16
17
|
'@atlaskit/platform/no-invalid-feature-flag-usage': string;
|
|
18
|
+
'@atlaskit/platform/no-invalid-storybook-decorator-usage': string;
|
|
17
19
|
};
|
|
18
20
|
};
|
|
19
21
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/eslint-plugin-platform",
|
|
3
3
|
"description": "The essential plugin for use with Atlassian frontend platform tools",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"atlassian": {
|
|
7
7
|
"team": "UIP - Platform Integration Trust (PITa)",
|
package/report.api.md
CHANGED
|
@@ -27,6 +27,7 @@ export const configs: {
|
|
|
27
27
|
'@atlaskit/platform/ensure-test-runner-arguments': string;
|
|
28
28
|
'@atlaskit/platform/ensure-test-runner-nested-count': string;
|
|
29
29
|
'@atlaskit/platform/no-invalid-feature-flag-usage': string;
|
|
30
|
+
'@atlaskit/platform/no-invalid-storybook-decorator-usage': string;
|
|
30
31
|
};
|
|
31
32
|
};
|
|
32
33
|
};
|
|
@@ -43,6 +44,7 @@ export const rules: {
|
|
|
43
44
|
'ensure-test-runner-nested-count': Rule.RuleModule;
|
|
44
45
|
'no-invalid-feature-flag-usage': Rule.RuleModule;
|
|
45
46
|
'no-pre-post-install-scripts': Rule.RuleModule;
|
|
47
|
+
'no-invalid-storybook-decorator-usage': Rule.RuleModule;
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
// (No @packageDocumentation comment for this package)
|
package/src/index.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import noPreAndPostInstallScripts from './rules/no-pre-post-installs';
|
|
|
4
4
|
import ensureTestRunnerArguments from './rules/ensure-test-runner-arguments';
|
|
5
5
|
import ensureTestRunnerNestedCount from './rules/ensure-test-runner-nested-count';
|
|
6
6
|
import noInvalidFeatureFlagUsage from './rules/no-invalid-feature-flag-usage';
|
|
7
|
+
import noInvalidStorybookDecoratorUsage from './rules/no-invalid-storybook-decorator-usage';
|
|
7
8
|
|
|
8
9
|
export const rules = {
|
|
9
10
|
'ensure-feature-flag-registration': ensureFeatureFlagRegistration,
|
|
@@ -11,6 +12,7 @@ export const rules = {
|
|
|
11
12
|
'ensure-test-runner-nested-count': ensureTestRunnerNestedCount,
|
|
12
13
|
'no-invalid-feature-flag-usage': noInvalidFeatureFlagUsage,
|
|
13
14
|
'no-pre-post-install-scripts': noPreAndPostInstallScripts,
|
|
15
|
+
'no-invalid-storybook-decorator-usage': noInvalidStorybookDecoratorUsage,
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
export const configs = {
|
|
@@ -21,6 +23,7 @@ export const configs = {
|
|
|
21
23
|
'@atlaskit/platform/ensure-test-runner-arguments': 'error',
|
|
22
24
|
'@atlaskit/platform/ensure-test-runner-nested-count': 'warn',
|
|
23
25
|
'@atlaskit/platform/no-invalid-feature-flag-usage': 'error',
|
|
26
|
+
'@atlaskit/platform/no-invalid-storybook-decorator-usage': 'error',
|
|
24
27
|
},
|
|
25
28
|
},
|
|
26
29
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { tester } from '../../../../__tests__/utils/_tester';
|
|
2
|
+
import rule from '../../index';
|
|
3
|
+
|
|
4
|
+
describe('no-invalid-storybook-decorator-usage tests', () => {
|
|
5
|
+
tester.run('no-invalid-storybook-decorator-usage', rule, {
|
|
6
|
+
valid: [
|
|
7
|
+
{
|
|
8
|
+
code: `withPlatformFeatureFlags({})(<SampleComponent/>)`,
|
|
9
|
+
},
|
|
10
|
+
],
|
|
11
|
+
invalid: [
|
|
12
|
+
{
|
|
13
|
+
code: `const flags = {'uip.sample.color': true}; withPlatformFeatureFlags(flags)(<SampleComponent/>)`,
|
|
14
|
+
errors: [{ messageId: 'onlyObjectExpression' }],
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
|
|
3
|
+
const STORYBOOK_DECORATOR_IDENTIFIER = 'withPlatformFeatureFlags' as const;
|
|
4
|
+
|
|
5
|
+
const rule: Rule.RuleModule = {
|
|
6
|
+
meta: {
|
|
7
|
+
hasSuggestions: false,
|
|
8
|
+
docs: {
|
|
9
|
+
recommended: false,
|
|
10
|
+
},
|
|
11
|
+
type: 'problem',
|
|
12
|
+
messages: {
|
|
13
|
+
onlyObjectExpression:
|
|
14
|
+
'Only object literals allowed in the storybook decorator! See http://go/pff-eslint for more details',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
create(context) {
|
|
18
|
+
return {
|
|
19
|
+
[`CallExpression[callee.name=/${STORYBOOK_DECORATOR_IDENTIFIER}/]`]: (
|
|
20
|
+
node: Rule.Node,
|
|
21
|
+
) => {
|
|
22
|
+
// to make typescript happy
|
|
23
|
+
if (node.type === 'CallExpression') {
|
|
24
|
+
const args = node.arguments;
|
|
25
|
+
|
|
26
|
+
if (args.length === 1 && args[0].type !== 'ObjectExpression') {
|
|
27
|
+
return context.report({
|
|
28
|
+
node,
|
|
29
|
+
messageId: 'onlyObjectExpression',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {};
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default rule;
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export const configs: {
|
|
|
16
16
|
'@atlaskit/platform/ensure-test-runner-arguments': string;
|
|
17
17
|
'@atlaskit/platform/ensure-test-runner-nested-count': string;
|
|
18
18
|
'@atlaskit/platform/no-invalid-feature-flag-usage': string;
|
|
19
|
+
'@atlaskit/platform/no-invalid-storybook-decorator-usage': string;
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
22
|
};
|
|
@@ -32,6 +33,7 @@ export const rules: {
|
|
|
32
33
|
'ensure-test-runner-nested-count': Rule.RuleModule;
|
|
33
34
|
'no-invalid-feature-flag-usage': Rule.RuleModule;
|
|
34
35
|
'no-pre-post-install-scripts': Rule.RuleModule;
|
|
36
|
+
'no-invalid-storybook-decorator-usage': Rule.RuleModule;
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
// (No @packageDocumentation comment for this package)
|