@atlaskit/eslint-plugin-platform 0.1.7 → 0.1.8

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/eslint-plugin-platform
2
2
 
3
+ ## 0.1.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [`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
8
+
3
9
  ## 0.1.7
4
10
 
5
11
  ### 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
- // check registration section for valid feature flag prefixes.
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
- v: context.report({
60
- node: args[0],
61
- messageId: 'featureFlagIncorrectPrefix',
62
- data: {
63
- allowedPrefixes: allowedPrefixes.map(function (p) {
64
- return "".concat(p);
65
- }).join(','),
66
- featureFlag: featureFlag
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 {};
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-platform",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "sideEffects": false
5
5
  }
@@ -41,10 +41,8 @@ const rule = {
41
41
  if (!platformFeatureFlags) {
42
42
  return {};
43
43
  }
44
-
45
- // check registration section for valid feature flag prefixes.
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],
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-platform",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "sideEffects": false
5
5
  }
@@ -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
- // check registration section for valid feature flag prefixes.
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
- v: context.report({
53
- node: args[0],
54
- messageId: 'featureFlagIncorrectPrefix',
55
- data: {
56
- allowedPrefixes: allowedPrefixes.map(function (p) {
57
- return "".concat(p);
58
- }).join(','),
59
- featureFlag: featureFlag
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 {};
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-platform",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "sideEffects": false
5
5
  }
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.7",
4
+ "version": "0.1.8",
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('with flag with invalid prefix', () => {
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
- // check registration section for valid feature flag prefixes.
63
- // this checks all flags at every call site to ensure that new flags show errors as soon as possible.
64
- for (const featureFlag in platformFeatureFlags) {
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),