@atlaskit/eslint-plugin-platform 0.2.3 → 0.2.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 +12 -0
- package/dist/cjs/index.js +7 -2
- package/dist/cjs/rules/ensure-atlassian-team/index.js +50 -0
- package/dist/cjs/rules/ensure-publish-valid/index.js +99 -0
- package/dist/es2019/index.js +7 -2
- package/dist/es2019/rules/ensure-atlassian-team/index.js +39 -0
- package/dist/es2019/rules/ensure-publish-valid/index.js +87 -0
- package/dist/esm/index.js +7 -2
- package/dist/esm/rules/ensure-atlassian-team/index.js +43 -0
- package/dist/esm/rules/ensure-publish-valid/index.js +92 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/rules/ensure-atlassian-team/index.d.ts +3 -0
- package/dist/types/rules/ensure-publish-valid/index.d.ts +3 -0
- package/dist/types-ts4.5/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/ensure-atlassian-team/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/ensure-publish-valid/index.d.ts +3 -0
- package/package.json +1 -1
- package/report.api.md +3 -0
- package/src/index.tsx +5 -0
- package/src/rules/ensure-atlassian-team/__tests__/unit/rule.test.ts +24 -0
- package/src/rules/ensure-atlassian-team/index.ts +63 -0
- package/src/rules/ensure-publish-valid/__tests__/unit/rule.test.ts +41 -0
- package/src/rules/ensure-publish-valid/index.ts +134 -0
- package/tmp/api-report-tmp.d.ts +3 -0
- package/dist/cjs/version.json +0 -5
- package/dist/es2019/version.json +0 -5
- package/dist/esm/version.json +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-platform
|
|
2
2
|
|
|
3
|
+
## 0.2.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e5f52093b2a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e5f52093b2a) - Add a rule to ensure that publish config is correct for packages
|
|
8
|
+
|
|
9
|
+
## 0.2.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`eb64cbdd681`](https://bitbucket.org/atlassian/atlassian-frontend/commits/eb64cbdd681) - Add a new rule to verify that the atlassian team is defined if the relevant section exists in the package.json
|
|
14
|
+
|
|
3
15
|
## 0.2.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -9,17 +9,21 @@ var _ensureFeatureFlagRegistration = _interopRequireDefault(require("./rules/ens
|
|
|
9
9
|
var _noPrePostInstalls = _interopRequireDefault(require("./rules/no-pre-post-installs"));
|
|
10
10
|
var _ensureTestRunnerArguments = _interopRequireDefault(require("./rules/ensure-test-runner-arguments"));
|
|
11
11
|
var _ensureTestRunnerNestedCount = _interopRequireDefault(require("./rules/ensure-test-runner-nested-count"));
|
|
12
|
+
var _ensureAtlassianTeam = _interopRequireDefault(require("./rules/ensure-atlassian-team"));
|
|
12
13
|
var _noInvalidFeatureFlagUsage = _interopRequireDefault(require("./rules/no-invalid-feature-flag-usage"));
|
|
13
14
|
var _ensureFeatureFlagPrefix = _interopRequireDefault(require("./rules/ensure-feature-flag-prefix"));
|
|
14
15
|
var _noInvalidStorybookDecoratorUsage = _interopRequireDefault(require("./rules/no-invalid-storybook-decorator-usage"));
|
|
16
|
+
var _ensurePublishValid = _interopRequireDefault(require("./rules/ensure-publish-valid"));
|
|
15
17
|
var rules = {
|
|
16
18
|
'ensure-feature-flag-registration': _ensureFeatureFlagRegistration.default,
|
|
17
19
|
'ensure-feature-flag-prefix': _ensureFeatureFlagPrefix.default,
|
|
18
20
|
'ensure-test-runner-arguments': _ensureTestRunnerArguments.default,
|
|
19
21
|
'ensure-test-runner-nested-count': _ensureTestRunnerNestedCount.default,
|
|
22
|
+
'ensure-atlassian-team': _ensureAtlassianTeam.default,
|
|
20
23
|
'no-invalid-feature-flag-usage': _noInvalidFeatureFlagUsage.default,
|
|
21
24
|
'no-pre-post-install-scripts': _noPrePostInstalls.default,
|
|
22
|
-
'no-invalid-storybook-decorator-usage': _noInvalidStorybookDecoratorUsage.default
|
|
25
|
+
'no-invalid-storybook-decorator-usage': _noInvalidStorybookDecoratorUsage.default,
|
|
26
|
+
'ensure-publish-valid': _ensurePublishValid.default
|
|
23
27
|
};
|
|
24
28
|
exports.rules = rules;
|
|
25
29
|
var configs = {
|
|
@@ -33,7 +37,8 @@ var configs = {
|
|
|
33
37
|
'@atlaskit/platform/ensure-test-runner-arguments': 'error',
|
|
34
38
|
'@atlaskit/platform/ensure-test-runner-nested-count': 'warn',
|
|
35
39
|
'@atlaskit/platform/no-invalid-feature-flag-usage': 'error',
|
|
36
|
-
'@atlaskit/platform/no-invalid-storybook-decorator-usage': 'error'
|
|
40
|
+
'@atlaskit/platform/no-invalid-storybook-decorator-usage': 'error',
|
|
41
|
+
'@atlaskit/platform/ensure-atlassian-team': 'error'
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
44
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var rule = {
|
|
8
|
+
meta: {
|
|
9
|
+
type: 'problem',
|
|
10
|
+
docs: {
|
|
11
|
+
description: 'This rule ensures that the internal packages have a responsible team attached.',
|
|
12
|
+
recommended: true
|
|
13
|
+
},
|
|
14
|
+
hasSuggestions: false,
|
|
15
|
+
messages: {
|
|
16
|
+
atlassianTeamRequired: 'The atlassian.team property is required'
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
create: function create(context) {
|
|
20
|
+
return {
|
|
21
|
+
ObjectExpression: function ObjectExpression(node) {
|
|
22
|
+
if (!context.getFilename().endsWith('package.json') || node.type !== 'ObjectExpression') {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
var atlassianProp = node.properties.find(function (p) {
|
|
26
|
+
return p.type === 'Property' && p.key.type === 'Literal' && p.key.value === 'atlassian';
|
|
27
|
+
});
|
|
28
|
+
if (!atlassianProp) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (atlassianProp.type !== 'Property' || atlassianProp.value.type !== 'ObjectExpression') {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
var teamProp = atlassianProp.value.properties.find(function (p) {
|
|
35
|
+
return p.type === 'Property' && p.key.type === 'Literal' && p.key.value === 'team';
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// this just checks for existence, we can potentially cross-reference it with teams.json to make sure its valid in the future.
|
|
39
|
+
if (!teamProp) {
|
|
40
|
+
return context.report({
|
|
41
|
+
node: node,
|
|
42
|
+
messageId: 'atlassianTeamRequired'
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var _default = rule;
|
|
50
|
+
exports.default = _default;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var getObjectPropertyAsLiteral = function getObjectPropertyAsLiteral(node, property) {
|
|
8
|
+
var prop = node.properties.find(function (p) {
|
|
9
|
+
return p.type === 'Property' && p.key.type === 'Literal' && p.key.value === property;
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// double check for property is to make typescript happy
|
|
13
|
+
if ((prop === null || prop === void 0 ? void 0 : prop.type) === 'Property' && (prop === null || prop === void 0 ? void 0 : prop.value.type) === 'Literal') {
|
|
14
|
+
var _prop$value$value;
|
|
15
|
+
return (_prop$value$value = prop.value.value) !== null && _prop$value$value !== void 0 ? _prop$value$value : null;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
};
|
|
19
|
+
var getObjectPropertyAsObject = function getObjectPropertyAsObject(node, property) {
|
|
20
|
+
var prop = node.properties.find(function (p) {
|
|
21
|
+
return p.type === 'Property' && p.key.type === 'Literal' && p.key.value === property;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// double check for property is to make typescript happy
|
|
25
|
+
if ((prop === null || prop === void 0 ? void 0 : prop.type) === 'Property' && (prop === null || prop === void 0 ? void 0 : prop.value.type) === 'ObjectExpression') {
|
|
26
|
+
var _prop$value;
|
|
27
|
+
return (_prop$value = prop.value) !== null && _prop$value !== void 0 ? _prop$value : null;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
var rule = {
|
|
32
|
+
meta: {
|
|
33
|
+
type: 'problem',
|
|
34
|
+
docs: {
|
|
35
|
+
description: 'This rule ensures that the package.json for your packages are set up correctly for publishing depending on the package name prefix',
|
|
36
|
+
recommended: true
|
|
37
|
+
},
|
|
38
|
+
hasSuggestions: false,
|
|
39
|
+
schema: [{
|
|
40
|
+
type: 'object',
|
|
41
|
+
properties: {
|
|
42
|
+
exceptions: {
|
|
43
|
+
type: 'array',
|
|
44
|
+
items: [{
|
|
45
|
+
type: 'string'
|
|
46
|
+
}]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}],
|
|
50
|
+
messages: {
|
|
51
|
+
publishConfigRequired: '@atlaskit prefix is public! You have to specify a `publishConfig`, (package {{packageName}}) see https://go.atlassian.com/package-namespace',
|
|
52
|
+
noPrivate: 'setting private to true prevents publishing, your package prefix implies you want to publish! (package {{packageName}}) see https://go.atlassian.com/package-namespace'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
create: function create(context) {
|
|
56
|
+
var _ref2, _context$options;
|
|
57
|
+
var _ref = (_ref2 = (_context$options = context.options) === null || _context$options === void 0 ? void 0 : _context$options[0]) !== null && _ref2 !== void 0 ? _ref2 : {},
|
|
58
|
+
exceptions = _ref.exceptions;
|
|
59
|
+
return {
|
|
60
|
+
ObjectExpression: function ObjectExpression(node) {
|
|
61
|
+
if (!context.getFilename().endsWith('package.json') || node.type !== 'ObjectExpression') {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
var packageName = getObjectPropertyAsLiteral(node, 'name');
|
|
65
|
+
var packagePrivate = getObjectPropertyAsLiteral(node, 'private');
|
|
66
|
+
var packagePublishConfig = getObjectPropertyAsObject(node, 'publishConfig');
|
|
67
|
+
|
|
68
|
+
// exit if package is on known exception list
|
|
69
|
+
if (exceptions && exceptions.findIndex(function (name) {
|
|
70
|
+
return name === packageName;
|
|
71
|
+
}) !== -1) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (typeof packageName === 'string' && packageName.startsWith('@atlaskit')) {
|
|
75
|
+
if (typeof packagePrivate === 'boolean' && packagePrivate) {
|
|
76
|
+
return context.report({
|
|
77
|
+
node: node,
|
|
78
|
+
messageId: 'noPrivate',
|
|
79
|
+
data: {
|
|
80
|
+
packageName: packageName
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (packagePublishConfig === null) {
|
|
85
|
+
return context.report({
|
|
86
|
+
node: node,
|
|
87
|
+
messageId: 'publishConfigRequired',
|
|
88
|
+
data: {
|
|
89
|
+
packageName: packageName
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var _default = rule;
|
|
99
|
+
exports.default = _default;
|
package/dist/es2019/index.js
CHANGED
|
@@ -2,17 +2,21 @@ import ensureFeatureFlagRegistration from './rules/ensure-feature-flag-registrat
|
|
|
2
2
|
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
|
+
import ensureAtlassianTeam from './rules/ensure-atlassian-team';
|
|
5
6
|
import noInvalidFeatureFlagUsage from './rules/no-invalid-feature-flag-usage';
|
|
6
7
|
import ensureFeatureFlagPrefix from './rules/ensure-feature-flag-prefix';
|
|
7
8
|
import noInvalidStorybookDecoratorUsage from './rules/no-invalid-storybook-decorator-usage';
|
|
9
|
+
import ensurePublishValid from './rules/ensure-publish-valid';
|
|
8
10
|
export const rules = {
|
|
9
11
|
'ensure-feature-flag-registration': ensureFeatureFlagRegistration,
|
|
10
12
|
'ensure-feature-flag-prefix': ensureFeatureFlagPrefix,
|
|
11
13
|
'ensure-test-runner-arguments': ensureTestRunnerArguments,
|
|
12
14
|
'ensure-test-runner-nested-count': ensureTestRunnerNestedCount,
|
|
15
|
+
'ensure-atlassian-team': ensureAtlassianTeam,
|
|
13
16
|
'no-invalid-feature-flag-usage': noInvalidFeatureFlagUsage,
|
|
14
17
|
'no-pre-post-install-scripts': noPreAndPostInstallScripts,
|
|
15
|
-
'no-invalid-storybook-decorator-usage': noInvalidStorybookDecoratorUsage
|
|
18
|
+
'no-invalid-storybook-decorator-usage': noInvalidStorybookDecoratorUsage,
|
|
19
|
+
'ensure-publish-valid': ensurePublishValid
|
|
16
20
|
};
|
|
17
21
|
export const configs = {
|
|
18
22
|
recommended: {
|
|
@@ -25,7 +29,8 @@ export const configs = {
|
|
|
25
29
|
'@atlaskit/platform/ensure-test-runner-arguments': 'error',
|
|
26
30
|
'@atlaskit/platform/ensure-test-runner-nested-count': 'warn',
|
|
27
31
|
'@atlaskit/platform/no-invalid-feature-flag-usage': 'error',
|
|
28
|
-
'@atlaskit/platform/no-invalid-storybook-decorator-usage': 'error'
|
|
32
|
+
'@atlaskit/platform/no-invalid-storybook-decorator-usage': 'error',
|
|
33
|
+
'@atlaskit/platform/ensure-atlassian-team': 'error'
|
|
29
34
|
}
|
|
30
35
|
}
|
|
31
36
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const rule = {
|
|
2
|
+
meta: {
|
|
3
|
+
type: 'problem',
|
|
4
|
+
docs: {
|
|
5
|
+
description: 'This rule ensures that the internal packages have a responsible team attached.',
|
|
6
|
+
recommended: true
|
|
7
|
+
},
|
|
8
|
+
hasSuggestions: false,
|
|
9
|
+
messages: {
|
|
10
|
+
atlassianTeamRequired: 'The atlassian.team property is required'
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
create(context) {
|
|
14
|
+
return {
|
|
15
|
+
ObjectExpression: node => {
|
|
16
|
+
if (!context.getFilename().endsWith('package.json') || node.type !== 'ObjectExpression') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const atlassianProp = node.properties.find(p => p.type === 'Property' && p.key.type === 'Literal' && p.key.value === 'atlassian');
|
|
20
|
+
if (!atlassianProp) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (atlassianProp.type !== 'Property' || atlassianProp.value.type !== 'ObjectExpression') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const teamProp = atlassianProp.value.properties.find(p => p.type === 'Property' && p.key.type === 'Literal' && p.key.value === 'team');
|
|
27
|
+
|
|
28
|
+
// this just checks for existence, we can potentially cross-reference it with teams.json to make sure its valid in the future.
|
|
29
|
+
if (!teamProp) {
|
|
30
|
+
return context.report({
|
|
31
|
+
node,
|
|
32
|
+
messageId: 'atlassianTeamRequired'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export default rule;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const getObjectPropertyAsLiteral = (node, property) => {
|
|
2
|
+
const prop = node.properties.find(p => p.type === 'Property' && p.key.type === 'Literal' && p.key.value === property);
|
|
3
|
+
|
|
4
|
+
// double check for property is to make typescript happy
|
|
5
|
+
if ((prop === null || prop === void 0 ? void 0 : prop.type) === 'Property' && (prop === null || prop === void 0 ? void 0 : prop.value.type) === 'Literal') {
|
|
6
|
+
var _prop$value$value;
|
|
7
|
+
return (_prop$value$value = prop.value.value) !== null && _prop$value$value !== void 0 ? _prop$value$value : null;
|
|
8
|
+
}
|
|
9
|
+
return null;
|
|
10
|
+
};
|
|
11
|
+
const getObjectPropertyAsObject = (node, property) => {
|
|
12
|
+
const prop = node.properties.find(p => p.type === 'Property' && p.key.type === 'Literal' && p.key.value === property);
|
|
13
|
+
|
|
14
|
+
// double check for property is to make typescript happy
|
|
15
|
+
if ((prop === null || prop === void 0 ? void 0 : prop.type) === 'Property' && (prop === null || prop === void 0 ? void 0 : prop.value.type) === 'ObjectExpression') {
|
|
16
|
+
var _prop$value;
|
|
17
|
+
return (_prop$value = prop.value) !== null && _prop$value !== void 0 ? _prop$value : null;
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
const rule = {
|
|
22
|
+
meta: {
|
|
23
|
+
type: 'problem',
|
|
24
|
+
docs: {
|
|
25
|
+
description: 'This rule ensures that the package.json for your packages are set up correctly for publishing depending on the package name prefix',
|
|
26
|
+
recommended: true
|
|
27
|
+
},
|
|
28
|
+
hasSuggestions: false,
|
|
29
|
+
schema: [{
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {
|
|
32
|
+
exceptions: {
|
|
33
|
+
type: 'array',
|
|
34
|
+
items: [{
|
|
35
|
+
type: 'string'
|
|
36
|
+
}]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}],
|
|
40
|
+
messages: {
|
|
41
|
+
publishConfigRequired: '@atlaskit prefix is public! You have to specify a `publishConfig`, (package {{packageName}}) see https://go.atlassian.com/package-namespace',
|
|
42
|
+
noPrivate: 'setting private to true prevents publishing, your package prefix implies you want to publish! (package {{packageName}}) see https://go.atlassian.com/package-namespace'
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
create(context) {
|
|
46
|
+
var _ref, _context$options;
|
|
47
|
+
const {
|
|
48
|
+
exceptions
|
|
49
|
+
} = (_ref = (_context$options = context.options) === null || _context$options === void 0 ? void 0 : _context$options[0]) !== null && _ref !== void 0 ? _ref : {};
|
|
50
|
+
return {
|
|
51
|
+
ObjectExpression: node => {
|
|
52
|
+
if (!context.getFilename().endsWith('package.json') || node.type !== 'ObjectExpression') {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const packageName = getObjectPropertyAsLiteral(node, 'name');
|
|
56
|
+
const packagePrivate = getObjectPropertyAsLiteral(node, 'private');
|
|
57
|
+
const packagePublishConfig = getObjectPropertyAsObject(node, 'publishConfig');
|
|
58
|
+
|
|
59
|
+
// exit if package is on known exception list
|
|
60
|
+
if (exceptions && exceptions.findIndex(name => name === packageName) !== -1) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (typeof packageName === 'string' && packageName.startsWith('@atlaskit')) {
|
|
64
|
+
if (typeof packagePrivate === 'boolean' && packagePrivate) {
|
|
65
|
+
return context.report({
|
|
66
|
+
node,
|
|
67
|
+
messageId: 'noPrivate',
|
|
68
|
+
data: {
|
|
69
|
+
packageName
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (packagePublishConfig === null) {
|
|
74
|
+
return context.report({
|
|
75
|
+
node,
|
|
76
|
+
messageId: 'publishConfigRequired',
|
|
77
|
+
data: {
|
|
78
|
+
packageName
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
export default rule;
|
package/dist/esm/index.js
CHANGED
|
@@ -2,17 +2,21 @@ import ensureFeatureFlagRegistration from './rules/ensure-feature-flag-registrat
|
|
|
2
2
|
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
|
+
import ensureAtlassianTeam from './rules/ensure-atlassian-team';
|
|
5
6
|
import noInvalidFeatureFlagUsage from './rules/no-invalid-feature-flag-usage';
|
|
6
7
|
import ensureFeatureFlagPrefix from './rules/ensure-feature-flag-prefix';
|
|
7
8
|
import noInvalidStorybookDecoratorUsage from './rules/no-invalid-storybook-decorator-usage';
|
|
9
|
+
import ensurePublishValid from './rules/ensure-publish-valid';
|
|
8
10
|
export var rules = {
|
|
9
11
|
'ensure-feature-flag-registration': ensureFeatureFlagRegistration,
|
|
10
12
|
'ensure-feature-flag-prefix': ensureFeatureFlagPrefix,
|
|
11
13
|
'ensure-test-runner-arguments': ensureTestRunnerArguments,
|
|
12
14
|
'ensure-test-runner-nested-count': ensureTestRunnerNestedCount,
|
|
15
|
+
'ensure-atlassian-team': ensureAtlassianTeam,
|
|
13
16
|
'no-invalid-feature-flag-usage': noInvalidFeatureFlagUsage,
|
|
14
17
|
'no-pre-post-install-scripts': noPreAndPostInstallScripts,
|
|
15
|
-
'no-invalid-storybook-decorator-usage': noInvalidStorybookDecoratorUsage
|
|
18
|
+
'no-invalid-storybook-decorator-usage': noInvalidStorybookDecoratorUsage,
|
|
19
|
+
'ensure-publish-valid': ensurePublishValid
|
|
16
20
|
};
|
|
17
21
|
export var configs = {
|
|
18
22
|
recommended: {
|
|
@@ -25,7 +29,8 @@ export var configs = {
|
|
|
25
29
|
'@atlaskit/platform/ensure-test-runner-arguments': 'error',
|
|
26
30
|
'@atlaskit/platform/ensure-test-runner-nested-count': 'warn',
|
|
27
31
|
'@atlaskit/platform/no-invalid-feature-flag-usage': 'error',
|
|
28
|
-
'@atlaskit/platform/no-invalid-storybook-decorator-usage': 'error'
|
|
32
|
+
'@atlaskit/platform/no-invalid-storybook-decorator-usage': 'error',
|
|
33
|
+
'@atlaskit/platform/ensure-atlassian-team': 'error'
|
|
29
34
|
}
|
|
30
35
|
}
|
|
31
36
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var rule = {
|
|
2
|
+
meta: {
|
|
3
|
+
type: 'problem',
|
|
4
|
+
docs: {
|
|
5
|
+
description: 'This rule ensures that the internal packages have a responsible team attached.',
|
|
6
|
+
recommended: true
|
|
7
|
+
},
|
|
8
|
+
hasSuggestions: false,
|
|
9
|
+
messages: {
|
|
10
|
+
atlassianTeamRequired: 'The atlassian.team property is required'
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
create: function create(context) {
|
|
14
|
+
return {
|
|
15
|
+
ObjectExpression: function ObjectExpression(node) {
|
|
16
|
+
if (!context.getFilename().endsWith('package.json') || node.type !== 'ObjectExpression') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
var atlassianProp = node.properties.find(function (p) {
|
|
20
|
+
return p.type === 'Property' && p.key.type === 'Literal' && p.key.value === 'atlassian';
|
|
21
|
+
});
|
|
22
|
+
if (!atlassianProp) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (atlassianProp.type !== 'Property' || atlassianProp.value.type !== 'ObjectExpression') {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
var teamProp = atlassianProp.value.properties.find(function (p) {
|
|
29
|
+
return p.type === 'Property' && p.key.type === 'Literal' && p.key.value === 'team';
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// this just checks for existence, we can potentially cross-reference it with teams.json to make sure its valid in the future.
|
|
33
|
+
if (!teamProp) {
|
|
34
|
+
return context.report({
|
|
35
|
+
node: node,
|
|
36
|
+
messageId: 'atlassianTeamRequired'
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
export default rule;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var getObjectPropertyAsLiteral = function getObjectPropertyAsLiteral(node, property) {
|
|
2
|
+
var prop = node.properties.find(function (p) {
|
|
3
|
+
return p.type === 'Property' && p.key.type === 'Literal' && p.key.value === property;
|
|
4
|
+
});
|
|
5
|
+
|
|
6
|
+
// double check for property is to make typescript happy
|
|
7
|
+
if ((prop === null || prop === void 0 ? void 0 : prop.type) === 'Property' && (prop === null || prop === void 0 ? void 0 : prop.value.type) === 'Literal') {
|
|
8
|
+
var _prop$value$value;
|
|
9
|
+
return (_prop$value$value = prop.value.value) !== null && _prop$value$value !== void 0 ? _prop$value$value : null;
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
};
|
|
13
|
+
var getObjectPropertyAsObject = function getObjectPropertyAsObject(node, property) {
|
|
14
|
+
var prop = node.properties.find(function (p) {
|
|
15
|
+
return p.type === 'Property' && p.key.type === 'Literal' && p.key.value === property;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// double check for property is to make typescript happy
|
|
19
|
+
if ((prop === null || prop === void 0 ? void 0 : prop.type) === 'Property' && (prop === null || prop === void 0 ? void 0 : prop.value.type) === 'ObjectExpression') {
|
|
20
|
+
var _prop$value;
|
|
21
|
+
return (_prop$value = prop.value) !== null && _prop$value !== void 0 ? _prop$value : null;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
};
|
|
25
|
+
var rule = {
|
|
26
|
+
meta: {
|
|
27
|
+
type: 'problem',
|
|
28
|
+
docs: {
|
|
29
|
+
description: 'This rule ensures that the package.json for your packages are set up correctly for publishing depending on the package name prefix',
|
|
30
|
+
recommended: true
|
|
31
|
+
},
|
|
32
|
+
hasSuggestions: false,
|
|
33
|
+
schema: [{
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
exceptions: {
|
|
37
|
+
type: 'array',
|
|
38
|
+
items: [{
|
|
39
|
+
type: 'string'
|
|
40
|
+
}]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}],
|
|
44
|
+
messages: {
|
|
45
|
+
publishConfigRequired: '@atlaskit prefix is public! You have to specify a `publishConfig`, (package {{packageName}}) see https://go.atlassian.com/package-namespace',
|
|
46
|
+
noPrivate: 'setting private to true prevents publishing, your package prefix implies you want to publish! (package {{packageName}}) see https://go.atlassian.com/package-namespace'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
create: function create(context) {
|
|
50
|
+
var _ref2, _context$options;
|
|
51
|
+
var _ref = (_ref2 = (_context$options = context.options) === null || _context$options === void 0 ? void 0 : _context$options[0]) !== null && _ref2 !== void 0 ? _ref2 : {},
|
|
52
|
+
exceptions = _ref.exceptions;
|
|
53
|
+
return {
|
|
54
|
+
ObjectExpression: function ObjectExpression(node) {
|
|
55
|
+
if (!context.getFilename().endsWith('package.json') || node.type !== 'ObjectExpression') {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
var packageName = getObjectPropertyAsLiteral(node, 'name');
|
|
59
|
+
var packagePrivate = getObjectPropertyAsLiteral(node, 'private');
|
|
60
|
+
var packagePublishConfig = getObjectPropertyAsObject(node, 'publishConfig');
|
|
61
|
+
|
|
62
|
+
// exit if package is on known exception list
|
|
63
|
+
if (exceptions && exceptions.findIndex(function (name) {
|
|
64
|
+
return name === packageName;
|
|
65
|
+
}) !== -1) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (typeof packageName === 'string' && packageName.startsWith('@atlaskit')) {
|
|
69
|
+
if (typeof packagePrivate === 'boolean' && packagePrivate) {
|
|
70
|
+
return context.report({
|
|
71
|
+
node: node,
|
|
72
|
+
messageId: 'noPrivate',
|
|
73
|
+
data: {
|
|
74
|
+
packageName: packageName
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (packagePublishConfig === null) {
|
|
79
|
+
return context.report({
|
|
80
|
+
node: node,
|
|
81
|
+
messageId: 'publishConfigRequired',
|
|
82
|
+
data: {
|
|
83
|
+
packageName: packageName
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
export default rule;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,9 +4,11 @@ export declare const rules: {
|
|
|
4
4
|
'ensure-feature-flag-prefix': import("eslint").Rule.RuleModule;
|
|
5
5
|
'ensure-test-runner-arguments': import("eslint").Rule.RuleModule;
|
|
6
6
|
'ensure-test-runner-nested-count': import("eslint").Rule.RuleModule;
|
|
7
|
+
'ensure-atlassian-team': import("eslint").Rule.RuleModule;
|
|
7
8
|
'no-invalid-feature-flag-usage': import("eslint").Rule.RuleModule;
|
|
8
9
|
'no-pre-post-install-scripts': import("eslint").Rule.RuleModule;
|
|
9
10
|
'no-invalid-storybook-decorator-usage': import("eslint").Rule.RuleModule;
|
|
11
|
+
'ensure-publish-valid': import("eslint").Rule.RuleModule;
|
|
10
12
|
};
|
|
11
13
|
export declare const configs: {
|
|
12
14
|
recommended: {
|
|
@@ -20,6 +22,7 @@ export declare const configs: {
|
|
|
20
22
|
'@atlaskit/platform/ensure-test-runner-nested-count': string;
|
|
21
23
|
'@atlaskit/platform/no-invalid-feature-flag-usage': string;
|
|
22
24
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': string;
|
|
25
|
+
'@atlaskit/platform/ensure-atlassian-team': string;
|
|
23
26
|
};
|
|
24
27
|
};
|
|
25
28
|
};
|
|
@@ -4,9 +4,11 @@ export declare const rules: {
|
|
|
4
4
|
'ensure-feature-flag-prefix': import("eslint").Rule.RuleModule;
|
|
5
5
|
'ensure-test-runner-arguments': import("eslint").Rule.RuleModule;
|
|
6
6
|
'ensure-test-runner-nested-count': import("eslint").Rule.RuleModule;
|
|
7
|
+
'ensure-atlassian-team': import("eslint").Rule.RuleModule;
|
|
7
8
|
'no-invalid-feature-flag-usage': import("eslint").Rule.RuleModule;
|
|
8
9
|
'no-pre-post-install-scripts': import("eslint").Rule.RuleModule;
|
|
9
10
|
'no-invalid-storybook-decorator-usage': import("eslint").Rule.RuleModule;
|
|
11
|
+
'ensure-publish-valid': import("eslint").Rule.RuleModule;
|
|
10
12
|
};
|
|
11
13
|
export declare const configs: {
|
|
12
14
|
recommended: {
|
|
@@ -20,6 +22,7 @@ export declare const configs: {
|
|
|
20
22
|
'@atlaskit/platform/ensure-test-runner-nested-count': string;
|
|
21
23
|
'@atlaskit/platform/no-invalid-feature-flag-usage': string;
|
|
22
24
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': string;
|
|
25
|
+
'@atlaskit/platform/ensure-atlassian-team': string;
|
|
23
26
|
};
|
|
24
27
|
};
|
|
25
28
|
};
|
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.2.
|
|
4
|
+
"version": "0.2.5",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"atlassian": {
|
|
7
7
|
"team": "UIP - Platform Integration Trust (PITa)",
|
package/report.api.md
CHANGED
|
@@ -34,6 +34,7 @@ export const configs: {
|
|
|
34
34
|
'@atlaskit/platform/ensure-test-runner-nested-count': string;
|
|
35
35
|
'@atlaskit/platform/no-invalid-feature-flag-usage': string;
|
|
36
36
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': string;
|
|
37
|
+
'@atlaskit/platform/ensure-atlassian-team': string;
|
|
37
38
|
};
|
|
38
39
|
};
|
|
39
40
|
};
|
|
@@ -49,9 +50,11 @@ export const rules: {
|
|
|
49
50
|
'ensure-feature-flag-prefix': Rule.RuleModule;
|
|
50
51
|
'ensure-test-runner-arguments': Rule.RuleModule;
|
|
51
52
|
'ensure-test-runner-nested-count': Rule.RuleModule;
|
|
53
|
+
'ensure-atlassian-team': Rule.RuleModule;
|
|
52
54
|
'no-invalid-feature-flag-usage': Rule.RuleModule;
|
|
53
55
|
'no-pre-post-install-scripts': Rule.RuleModule;
|
|
54
56
|
'no-invalid-storybook-decorator-usage': Rule.RuleModule;
|
|
57
|
+
'ensure-publish-valid': Rule.RuleModule;
|
|
55
58
|
};
|
|
56
59
|
|
|
57
60
|
// (No @packageDocumentation comment for this package)
|
package/src/index.tsx
CHANGED
|
@@ -3,18 +3,22 @@ import ensureFeatureFlagRegistration from './rules/ensure-feature-flag-registrat
|
|
|
3
3
|
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
|
+
import ensureAtlassianTeam from './rules/ensure-atlassian-team';
|
|
6
7
|
import noInvalidFeatureFlagUsage from './rules/no-invalid-feature-flag-usage';
|
|
7
8
|
import ensureFeatureFlagPrefix from './rules/ensure-feature-flag-prefix';
|
|
8
9
|
import noInvalidStorybookDecoratorUsage from './rules/no-invalid-storybook-decorator-usage';
|
|
10
|
+
import ensurePublishValid from './rules/ensure-publish-valid';
|
|
9
11
|
|
|
10
12
|
export const rules = {
|
|
11
13
|
'ensure-feature-flag-registration': ensureFeatureFlagRegistration,
|
|
12
14
|
'ensure-feature-flag-prefix': ensureFeatureFlagPrefix,
|
|
13
15
|
'ensure-test-runner-arguments': ensureTestRunnerArguments,
|
|
14
16
|
'ensure-test-runner-nested-count': ensureTestRunnerNestedCount,
|
|
17
|
+
'ensure-atlassian-team': ensureAtlassianTeam,
|
|
15
18
|
'no-invalid-feature-flag-usage': noInvalidFeatureFlagUsage,
|
|
16
19
|
'no-pre-post-install-scripts': noPreAndPostInstallScripts,
|
|
17
20
|
'no-invalid-storybook-decorator-usage': noInvalidStorybookDecoratorUsage,
|
|
21
|
+
'ensure-publish-valid': ensurePublishValid,
|
|
18
22
|
};
|
|
19
23
|
|
|
20
24
|
export const configs = {
|
|
@@ -30,6 +34,7 @@ export const configs = {
|
|
|
30
34
|
'@atlaskit/platform/ensure-test-runner-nested-count': 'warn',
|
|
31
35
|
'@atlaskit/platform/no-invalid-feature-flag-usage': 'error',
|
|
32
36
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': 'error',
|
|
37
|
+
'@atlaskit/platform/ensure-atlassian-team': 'error',
|
|
33
38
|
},
|
|
34
39
|
},
|
|
35
40
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { tester } from '../../../../__tests__/utils/_tester';
|
|
2
|
+
import rule from '../../index';
|
|
3
|
+
|
|
4
|
+
describe('test no-pre-post-installs rule', () => {
|
|
5
|
+
tester.run('no-pre-post-installs', rule, {
|
|
6
|
+
valid: [
|
|
7
|
+
{
|
|
8
|
+
code: `const foo = {}`,
|
|
9
|
+
filename: 'package.json',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
code: `const foo = { "atlassian": { "team": "bar" } }`,
|
|
13
|
+
filename: 'foo/package.json',
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
invalid: [
|
|
17
|
+
{
|
|
18
|
+
code: `const foo = { "atlassian": {} }`,
|
|
19
|
+
filename: 'foo/package.json',
|
|
20
|
+
errors: [{ messageId: 'atlassianTeamRequired' }],
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
|
|
3
|
+
const rule: Rule.RuleModule = {
|
|
4
|
+
meta: {
|
|
5
|
+
type: 'problem',
|
|
6
|
+
docs: {
|
|
7
|
+
description:
|
|
8
|
+
'This rule ensures that the internal packages have a responsible team attached.',
|
|
9
|
+
recommended: true,
|
|
10
|
+
},
|
|
11
|
+
hasSuggestions: false,
|
|
12
|
+
messages: {
|
|
13
|
+
atlassianTeamRequired: 'The atlassian.team property is required',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
create(context) {
|
|
17
|
+
return {
|
|
18
|
+
ObjectExpression: (node: Rule.Node) => {
|
|
19
|
+
if (
|
|
20
|
+
!context.getFilename().endsWith('package.json') ||
|
|
21
|
+
node.type !== 'ObjectExpression'
|
|
22
|
+
) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const atlassianProp = node.properties.find(
|
|
27
|
+
(p) =>
|
|
28
|
+
p.type === 'Property' &&
|
|
29
|
+
p.key.type === 'Literal' &&
|
|
30
|
+
p.key.value === 'atlassian',
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if (!atlassianProp) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (
|
|
38
|
+
atlassianProp.type !== 'Property' ||
|
|
39
|
+
atlassianProp.value.type !== 'ObjectExpression'
|
|
40
|
+
) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const teamProp = atlassianProp.value.properties.find(
|
|
45
|
+
(p) =>
|
|
46
|
+
p.type === 'Property' &&
|
|
47
|
+
p.key.type === 'Literal' &&
|
|
48
|
+
p.key.value === 'team',
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// this just checks for existence, we can potentially cross-reference it with teams.json to make sure its valid in the future.
|
|
52
|
+
if (!teamProp) {
|
|
53
|
+
return context.report({
|
|
54
|
+
node,
|
|
55
|
+
messageId: 'atlassianTeamRequired',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default rule;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { tester } from '../../../../__tests__/utils/_tester';
|
|
2
|
+
import rule from '../../index';
|
|
3
|
+
|
|
4
|
+
describe('test ensure-publish-valid-rule', () => {
|
|
5
|
+
tester.run('ensure-publish-valid', rule, {
|
|
6
|
+
valid: [
|
|
7
|
+
{
|
|
8
|
+
code: `const foo = { "name": "@af/test" }`,
|
|
9
|
+
filename: 'package.json',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
options: [{ exceptions: ['@atlaskit/test'] }],
|
|
13
|
+
code: `const foo = { "name": "@atlaskit/test" }`,
|
|
14
|
+
filename: 'package.json',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
code: `const foo = { "name": "@atlaskit/test", "private": false, "publishConfig": { "registry": "https://registry.npmjs.org/" } }`,
|
|
18
|
+
filename: 'foo/package.json',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
invalid: [
|
|
22
|
+
{
|
|
23
|
+
code: `const foo = { "name": "@atlaskit/test" }`,
|
|
24
|
+
filename: 'foo/package.json',
|
|
25
|
+
errors: [
|
|
26
|
+
{
|
|
27
|
+
messageId: 'publishConfigRequired',
|
|
28
|
+
data: { packageName: '@atlaskit/test' },
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
code: `const foo = { "name": "@atlaskit/test", "private": true, "publishConfig": { "registry": "https://registry.npmjs.org/" } }`,
|
|
34
|
+
filename: 'foo/package.json',
|
|
35
|
+
errors: [
|
|
36
|
+
{ messageId: 'noPrivate', data: { packageName: '@atlaskit/test' } },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import type {
|
|
3
|
+
ObjectExpression,
|
|
4
|
+
SimpleLiteral,
|
|
5
|
+
RegExpLiteral,
|
|
6
|
+
BigIntLiteral,
|
|
7
|
+
} from 'estree';
|
|
8
|
+
const getObjectPropertyAsLiteral = (
|
|
9
|
+
node: ObjectExpression,
|
|
10
|
+
property: string,
|
|
11
|
+
): SimpleLiteral['value'] | RegExpLiteral['value'] | BigIntLiteral['value'] => {
|
|
12
|
+
const prop = node.properties.find(
|
|
13
|
+
(p) =>
|
|
14
|
+
p.type === 'Property' &&
|
|
15
|
+
p.key.type === 'Literal' &&
|
|
16
|
+
p.key.value === property,
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
// double check for property is to make typescript happy
|
|
20
|
+
if (prop?.type === 'Property' && prop?.value.type === 'Literal') {
|
|
21
|
+
return prop.value.value ?? null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return null;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getObjectPropertyAsObject = (
|
|
28
|
+
node: ObjectExpression,
|
|
29
|
+
property: string,
|
|
30
|
+
): ObjectExpression | null => {
|
|
31
|
+
const prop = node.properties.find(
|
|
32
|
+
(p) =>
|
|
33
|
+
p.type === 'Property' &&
|
|
34
|
+
p.key.type === 'Literal' &&
|
|
35
|
+
p.key.value === property,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// double check for property is to make typescript happy
|
|
39
|
+
if (prop?.type === 'Property' && prop?.value.type === 'ObjectExpression') {
|
|
40
|
+
return prop.value ?? null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type RuleOptions = {
|
|
47
|
+
// exceptions to this rule, will be ignored
|
|
48
|
+
exceptions?: string[];
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const rule: Rule.RuleModule = {
|
|
52
|
+
meta: {
|
|
53
|
+
type: 'problem',
|
|
54
|
+
docs: {
|
|
55
|
+
description:
|
|
56
|
+
'This rule ensures that the package.json for your packages are set up correctly for publishing depending on the package name prefix',
|
|
57
|
+
recommended: true,
|
|
58
|
+
},
|
|
59
|
+
hasSuggestions: false,
|
|
60
|
+
schema: [
|
|
61
|
+
{
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {
|
|
64
|
+
exceptions: {
|
|
65
|
+
type: 'array',
|
|
66
|
+
items: [{ type: 'string' }],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
messages: {
|
|
72
|
+
publishConfigRequired:
|
|
73
|
+
'@atlaskit prefix is public! You have to specify a `publishConfig`, (package {{packageName}}) see https://go.atlassian.com/package-namespace',
|
|
74
|
+
noPrivate:
|
|
75
|
+
'setting private to true prevents publishing, your package prefix implies you want to publish! (package {{packageName}}) see https://go.atlassian.com/package-namespace',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
create(context) {
|
|
79
|
+
const { exceptions } = (context.options?.[0] as RuleOptions) ?? {};
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
ObjectExpression: (node: Rule.Node) => {
|
|
83
|
+
if (
|
|
84
|
+
!context.getFilename().endsWith('package.json') ||
|
|
85
|
+
node.type !== 'ObjectExpression'
|
|
86
|
+
) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const packageName = getObjectPropertyAsLiteral(node, 'name');
|
|
91
|
+
const packagePrivate = getObjectPropertyAsLiteral(node, 'private');
|
|
92
|
+
const packagePublishConfig = getObjectPropertyAsObject(
|
|
93
|
+
node,
|
|
94
|
+
'publishConfig',
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
// exit if package is on known exception list
|
|
98
|
+
if (
|
|
99
|
+
exceptions &&
|
|
100
|
+
exceptions.findIndex((name) => name === packageName) !== -1
|
|
101
|
+
) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (
|
|
106
|
+
typeof packageName === 'string' &&
|
|
107
|
+
packageName.startsWith('@atlaskit')
|
|
108
|
+
) {
|
|
109
|
+
if (typeof packagePrivate === 'boolean' && packagePrivate) {
|
|
110
|
+
return context.report({
|
|
111
|
+
node,
|
|
112
|
+
messageId: 'noPrivate',
|
|
113
|
+
data: {
|
|
114
|
+
packageName,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (packagePublishConfig === null) {
|
|
120
|
+
return context.report({
|
|
121
|
+
node,
|
|
122
|
+
messageId: 'publishConfigRequired',
|
|
123
|
+
data: {
|
|
124
|
+
packageName,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export default rule;
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export const configs: {
|
|
|
20
20
|
'@atlaskit/platform/ensure-test-runner-nested-count': string;
|
|
21
21
|
'@atlaskit/platform/no-invalid-feature-flag-usage': string;
|
|
22
22
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': string;
|
|
23
|
+
'@atlaskit/platform/ensure-atlassian-team': string;
|
|
23
24
|
};
|
|
24
25
|
};
|
|
25
26
|
};
|
|
@@ -35,9 +36,11 @@ export const rules: {
|
|
|
35
36
|
'ensure-feature-flag-prefix': Rule.RuleModule;
|
|
36
37
|
'ensure-test-runner-arguments': Rule.RuleModule;
|
|
37
38
|
'ensure-test-runner-nested-count': Rule.RuleModule;
|
|
39
|
+
'ensure-atlassian-team': Rule.RuleModule;
|
|
38
40
|
'no-invalid-feature-flag-usage': Rule.RuleModule;
|
|
39
41
|
'no-pre-post-install-scripts': Rule.RuleModule;
|
|
40
42
|
'no-invalid-storybook-decorator-usage': Rule.RuleModule;
|
|
43
|
+
'ensure-publish-valid': Rule.RuleModule;
|
|
41
44
|
};
|
|
42
45
|
|
|
43
46
|
// (No @packageDocumentation comment for this package)
|
package/dist/cjs/version.json
DELETED
package/dist/es2019/version.json
DELETED