@atlaskit/eslint-plugin-platform 0.1.7 → 0.2.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 +12 -0
- package/dist/cjs/rules/ensure-feature-flag-prefix/index.js +12 -22
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/rules/ensure-feature-flag-prefix/index.js +2 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/rules/ensure-feature-flag-prefix/index.js +12 -21
- package/dist/esm/version.json +1 -1
- package/dist/types/rules/util/registration-utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/rules/ensure-feature-flag-prefix/__tests__/unit/rule.test.tsx +14 -2
- package/src/rules/ensure-feature-flag-prefix/index.tsx +6 -3
- package/src/rules/ensure-test-runner-nested-count/index.tsx +1 -1
- package/src/rules/util/registration-utils.ts +1 -1
- package/tmp/api-report-tmp.d.ts +0 -45
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-platform
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip minor dependency bump
|
|
8
|
+
|
|
9
|
+
## 0.1.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`cb0e94d2ce4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cb0e94d2ce4) - Fix prefixes for all flags being checked at any callsite, only the current flag will be checked from now on
|
|
14
|
+
|
|
3
15
|
## 0.1.7
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
7
|
var _registrationUtils = require("../util/registration-utils");
|
|
10
8
|
var rule = {
|
|
11
9
|
meta: {
|
|
@@ -48,30 +46,22 @@ var rule = {
|
|
|
48
46
|
if (!platformFeatureFlags) {
|
|
49
47
|
return {};
|
|
50
48
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// this checks all flags at every call site to ensure that new flags show errors as soon as possible.
|
|
54
|
-
var _loop = function _loop(featureFlag) {
|
|
49
|
+
if (args.length === 1 && args[0].type === 'Literal' && args[0].raw) {
|
|
50
|
+
var featureFlag = args[0].value;
|
|
55
51
|
if (!allowedPrefixes.some(function (prefix) {
|
|
56
52
|
return featureFlag.startsWith(prefix);
|
|
57
53
|
})) {
|
|
58
|
-
return {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
})
|
|
69
|
-
};
|
|
54
|
+
return context.report({
|
|
55
|
+
node: args[0],
|
|
56
|
+
messageId: 'featureFlagIncorrectPrefix',
|
|
57
|
+
data: {
|
|
58
|
+
allowedPrefixes: allowedPrefixes.map(function (p) {
|
|
59
|
+
return "".concat(p);
|
|
60
|
+
}).join(','),
|
|
61
|
+
featureFlag: featureFlag
|
|
62
|
+
}
|
|
63
|
+
});
|
|
70
64
|
}
|
|
71
|
-
};
|
|
72
|
-
for (var featureFlag in platformFeatureFlags) {
|
|
73
|
-
var _ret = _loop(featureFlag);
|
|
74
|
-
if ((0, _typeof2.default)(_ret) === "object") return _ret.v;
|
|
75
65
|
}
|
|
76
66
|
}
|
|
77
67
|
return {};
|
package/dist/cjs/version.json
CHANGED
|
@@ -41,10 +41,8 @@ const rule = {
|
|
|
41
41
|
if (!platformFeatureFlags) {
|
|
42
42
|
return {};
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// this checks all flags at every call site to ensure that new flags show errors as soon as possible.
|
|
47
|
-
for (const featureFlag in platformFeatureFlags) {
|
|
44
|
+
if (args.length === 1 && args[0].type === 'Literal' && args[0].raw) {
|
|
45
|
+
const featureFlag = args[0].value;
|
|
48
46
|
if (!allowedPrefixes.some(prefix => featureFlag.startsWith(prefix))) {
|
|
49
47
|
return context.report({
|
|
50
48
|
node: args[0],
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
1
|
import { getMetadataForFilename, getterIdentifierToFlagTypeMap } from '../util/registration-utils';
|
|
3
2
|
var rule = {
|
|
4
3
|
meta: {
|
|
@@ -41,30 +40,22 @@ var rule = {
|
|
|
41
40
|
if (!platformFeatureFlags) {
|
|
42
41
|
return {};
|
|
43
42
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// this checks all flags at every call site to ensure that new flags show errors as soon as possible.
|
|
47
|
-
var _loop = function _loop(featureFlag) {
|
|
43
|
+
if (args.length === 1 && args[0].type === 'Literal' && args[0].raw) {
|
|
44
|
+
var featureFlag = args[0].value;
|
|
48
45
|
if (!allowedPrefixes.some(function (prefix) {
|
|
49
46
|
return featureFlag.startsWith(prefix);
|
|
50
47
|
})) {
|
|
51
|
-
return {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})
|
|
62
|
-
};
|
|
48
|
+
return context.report({
|
|
49
|
+
node: args[0],
|
|
50
|
+
messageId: 'featureFlagIncorrectPrefix',
|
|
51
|
+
data: {
|
|
52
|
+
allowedPrefixes: allowedPrefixes.map(function (p) {
|
|
53
|
+
return "".concat(p);
|
|
54
|
+
}).join(','),
|
|
55
|
+
featureFlag: featureFlag
|
|
56
|
+
}
|
|
57
|
+
});
|
|
63
58
|
}
|
|
64
|
-
};
|
|
65
|
-
for (var featureFlag in platformFeatureFlags) {
|
|
66
|
-
var _ret = _loop(featureFlag);
|
|
67
|
-
if (_typeof(_ret) === "object") return _ret.v;
|
|
68
59
|
}
|
|
69
60
|
}
|
|
70
61
|
return {};
|
package/dist/esm/version.json
CHANGED
|
@@ -6,7 +6,7 @@ export declare const getterIdentifierToFlagTypeMap: {
|
|
|
6
6
|
};
|
|
7
7
|
export declare type PlatformFeatureFlagRegistrationSection = {
|
|
8
8
|
[key: string]: {
|
|
9
|
-
type: typeof getterIdentifierToFlagTypeMap[keyof typeof getterIdentifierToFlagTypeMap];
|
|
9
|
+
type: (typeof getterIdentifierToFlagTypeMap)[keyof typeof getterIdentifierToFlagTypeMap];
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
12
|
export declare type EnhancedPackageJson = readPkgUp.PackageJson & {
|
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.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"atlassian": {
|
|
7
7
|
"team": "UIP - Platform Integration Trust (PITa)",
|
|
@@ -18,12 +18,15 @@ jest.mock('read-pkg-up', () => ({
|
|
|
18
18
|
}),
|
|
19
19
|
}));
|
|
20
20
|
|
|
21
|
-
describe('
|
|
21
|
+
describe('test prefix rule', () => {
|
|
22
22
|
beforeEach(() => {
|
|
23
23
|
mockPath = 'test/package.json';
|
|
24
24
|
|
|
25
25
|
mockPackageJson = {
|
|
26
26
|
'platform-feature-flags': {
|
|
27
|
+
'prefix-flag': {
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
},
|
|
27
30
|
'no-prefix-flag': {
|
|
28
31
|
type: 'boolean',
|
|
29
32
|
},
|
|
@@ -33,7 +36,16 @@ describe('with flag with invalid prefix', () => {
|
|
|
33
36
|
|
|
34
37
|
// this isolates the invalid case so we can test the suggestion properly
|
|
35
38
|
tester.run('ensure-feature-flag-registration', rule, {
|
|
36
|
-
valid: [
|
|
39
|
+
valid: [
|
|
40
|
+
{
|
|
41
|
+
options: [{ allowedPrefixes: ['prefix'] }],
|
|
42
|
+
code: `ffTest('prefix-flag')`,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
options: [{ allowedPrefixes: ['prefix'] }],
|
|
46
|
+
code: `getBooleanFF('prefix-flag')`,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
37
49
|
invalid: [
|
|
38
50
|
{
|
|
39
51
|
options: [{ allowedPrefixes: ['prefix'] }],
|
|
@@ -59,9 +59,12 @@ const rule: Rule.RuleModule = {
|
|
|
59
59
|
return {};
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
if (
|
|
63
|
+
args.length === 1 &&
|
|
64
|
+
args[0].type === 'Literal' &&
|
|
65
|
+
args[0].raw
|
|
66
|
+
) {
|
|
67
|
+
const featureFlag = args[0].value as string;
|
|
65
68
|
if (
|
|
66
69
|
!allowedPrefixes.some((prefix) =>
|
|
67
70
|
featureFlag.startsWith(prefix),
|
|
@@ -8,7 +8,7 @@ const getDepthOfNestedRunner = (
|
|
|
8
8
|
node: SimpleCallExpression & Rule.NodeParentExtension,
|
|
9
9
|
): number => {
|
|
10
10
|
// Calculate the depth of a binary tree, using a queue to track path
|
|
11
|
-
let queue: typeof node[] = [];
|
|
11
|
+
let queue: (typeof node)[] = [];
|
|
12
12
|
queue.push(node);
|
|
13
13
|
let depth = 0;
|
|
14
14
|
while (queue.length > 0) {
|
|
@@ -12,7 +12,7 @@ export const getterIdentifierToFlagTypeMap = {
|
|
|
12
12
|
export type PlatformFeatureFlagRegistrationSection = {
|
|
13
13
|
[key: string]: {
|
|
14
14
|
// get the values of the object above
|
|
15
|
-
type: typeof getterIdentifierToFlagTypeMap[keyof typeof getterIdentifierToFlagTypeMap];
|
|
15
|
+
type: (typeof getterIdentifierToFlagTypeMap)[keyof typeof getterIdentifierToFlagTypeMap];
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
|
package/tmp/api-report-tmp.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
## API Report File for "@atlaskit/eslint-plugin-platform"
|
|
2
|
-
|
|
3
|
-
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
|
|
7
|
-
import type { Linter } from 'eslint';
|
|
8
|
-
import { Rule } from 'eslint';
|
|
9
|
-
|
|
10
|
-
// @public (undocumented)
|
|
11
|
-
export const configs: {
|
|
12
|
-
recommended: {
|
|
13
|
-
plugins: string[];
|
|
14
|
-
rules: {
|
|
15
|
-
'@atlaskit/platform/ensure-feature-flag-registration': string;
|
|
16
|
-
'@atlaskit/platform/ensure-feature-flag-prefix': (string | {
|
|
17
|
-
allowedPrefixes: string[];
|
|
18
|
-
})[];
|
|
19
|
-
'@atlaskit/platform/ensure-test-runner-arguments': string;
|
|
20
|
-
'@atlaskit/platform/ensure-test-runner-nested-count': string;
|
|
21
|
-
'@atlaskit/platform/no-invalid-feature-flag-usage': string;
|
|
22
|
-
'@atlaskit/platform/no-invalid-storybook-decorator-usage': string;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// @public (undocumented)
|
|
28
|
-
export const processors: {
|
|
29
|
-
'package-json-processor': Linter.Processor<Linter.ProcessorFile | string>;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// @public (undocumented)
|
|
33
|
-
export const rules: {
|
|
34
|
-
'ensure-feature-flag-registration': Rule.RuleModule;
|
|
35
|
-
'ensure-feature-flag-prefix': Rule.RuleModule;
|
|
36
|
-
'ensure-test-runner-arguments': Rule.RuleModule;
|
|
37
|
-
'ensure-test-runner-nested-count': Rule.RuleModule;
|
|
38
|
-
'no-invalid-feature-flag-usage': Rule.RuleModule;
|
|
39
|
-
'no-pre-post-install-scripts': Rule.RuleModule;
|
|
40
|
-
'no-invalid-storybook-decorator-usage': Rule.RuleModule;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// (No @packageDocumentation comment for this package)
|
|
44
|
-
|
|
45
|
-
```
|