@atlaskit/eslint-plugin-platform 2.1.1 → 2.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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/eslint-plugin-platform
2
2
 
3
+ ## 2.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#103661](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103661)
8
+ [`976a915b13fc2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/976a915b13fc2) -
9
+ add flat config support
10
+
11
+ ## 2.1.2
12
+
13
+ ### Patch Changes
14
+
15
+ - [#102248](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102248)
16
+ [`05acb13c43541`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/05acb13c43541) -
17
+ AFB-825 Fixing edge case of expand-spacing-shorthand rule
18
+
3
19
  ## 2.1.1
4
20
 
5
21
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -4,8 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.rules = exports.processors = exports.configs = void 0;
7
+ exports.rules = exports.processors = exports.plugin = exports.default = exports.configs = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _eslintPlugin = _interopRequireDefault(require("@compiled/eslint-plugin"));
9
10
  var _ensureFeatureFlagRegistration = _interopRequireDefault(require("./rules/ensure-feature-flag-registration"));
10
11
  var _noPrePostInstalls = _interopRequireDefault(require("./rules/no-pre-post-installs"));
11
12
  var _ensureTestRunnerArguments = _interopRequireDefault(require("./rules/ensure-test-runner-arguments"));
@@ -34,6 +35,7 @@ var _expandBackgroundShorthand = _interopRequireDefault(require("./rules/compile
34
35
  var _expandSpacingShorthand = _interopRequireDefault(require("./rules/compiled/expand-spacing-shorthand"));
35
36
  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; }
36
37
  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) { (0, _defineProperty2.default)(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; } // eslint-disable-next-line import/no-extraneous-dependencies
38
+ var packageJson = require('@atlaskit/eslint-plugin-platform/package.json');
37
39
  var rules = exports.rules = {
38
40
  'ensure-feature-flag-registration': _ensureFeatureFlagRegistration.default,
39
41
  'ensure-feature-flag-prefix': _ensureFeatureFlagPrefix.default,
@@ -79,75 +81,115 @@ var commonConfig = {
79
81
  runtime: 'classic'
80
82
  }]
81
83
  };
82
- var configs = exports.configs = {
83
- recommended: {
84
- plugins: ['@atlaskit/platform', '@compiled'],
85
- rules: _objectSpread(_objectSpread({}, commonConfig), {}, {
86
- // See platform/packages/platform/eslint-plugin/src/rules/feature-gating/README.md
87
- // These rules are specific to `platform` and seem a WIP; jira and confluence currently have their own rules
88
- '@atlaskit/platform/no-module-level-eval': 'error',
89
- '@atlaskit/platform/static-feature-flags': 'error',
90
- '@atlaskit/platform/no-preconditioning': 'error',
91
- '@atlaskit/platform/inline-usage': 'error',
92
- '@atlaskit/platform/prefer-fg': 'error',
93
- '@atlaskit/platform/no-alias': 'error',
94
- // end: feature-gating rules
95
- '@atlaskit/platform/ensure-feature-flag-registration': 'error',
96
- '@atlaskit/platform/ensure-feature-flag-prefix': ['warn', {
97
- allowedPrefixes: ['platform.', 'platform_']
98
- }]
99
- })
100
- },
101
- jira: {
102
- plugins: ['@atlaskit/platform', '@compiled'],
103
- rules: _objectSpread({}, commonConfig)
104
- }
105
- };
84
+ var recommendedRules = _objectSpread(_objectSpread({}, commonConfig), {}, {
85
+ // See platform/packages/platform/eslint-plugin/src/rules/feature-gating/README.md
86
+ // These rules are specific to `platform` and seem a WIP; jira and confluence currently have their own rules
87
+ '@atlaskit/platform/no-module-level-eval': 'error',
88
+ '@atlaskit/platform/static-feature-flags': 'error',
89
+ '@atlaskit/platform/no-preconditioning': 'error',
90
+ '@atlaskit/platform/inline-usage': 'error',
91
+ '@atlaskit/platform/prefer-fg': 'error',
92
+ '@atlaskit/platform/no-alias': 'error',
93
+ // end: feature-gating rules
94
+ '@atlaskit/platform/ensure-feature-flag-registration': 'error',
95
+ '@atlaskit/platform/ensure-feature-flag-prefix': ['warn', {
96
+ allowedPrefixes: ['platform.', 'platform_']
97
+ }]
98
+ });
99
+ var jiraRules = commonConfig;
106
100
  var jsonPrefix = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, @typescript-eslint/semi, no-template-curly-in-string */ module.exports = ';
107
101
  var jsonPrefixForFlatConfig = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, no-template-curly-in-string */ module.exports = ';
108
- var processors = exports.processors = {
109
- 'package-json-processor': {
110
- preprocess: function preprocess(source) {
111
- // augment the json into a js file
112
- return [jsonPrefix + source.trim()];
102
+ var name = packageJson.name,
103
+ version = packageJson.version;
104
+ var plugin = exports.plugin = {
105
+ meta: {
106
+ name: name,
107
+ version: version
108
+ },
109
+ rules: rules,
110
+ configs: {
111
+ recommended: {
112
+ plugins: ['@atlaskit/platform', '@compiled'],
113
+ rules: recommendedRules
113
114
  },
114
- postprocess: function postprocess(messages) {
115
- return messages[0].map(function (message) {
116
- var fix = message.fix;
117
- if (!fix) {
118
- return message;
115
+ 'recommended/flat': {
116
+ plugins: {
117
+ get '@atlaskit/platform'() {
118
+ return plugin;
119
+ },
120
+ // @ts-expect-error there's an issue with the types for @compiled/eslint-plugin ('no-css-prop-without-css-function' specifically)
121
+ '@compiled': {
122
+ meta: _eslintPlugin.default.meta,
123
+ rules: _eslintPlugin.default.rules
119
124
  }
120
- var offset = jsonPrefix.length;
121
- return _objectSpread(_objectSpread({}, message), {}, {
122
- fix: _objectSpread(_objectSpread({}, fix), {}, {
123
- range: [fix.range[0] - offset, fix.range[1] - offset]
124
- })
125
- });
126
- });
125
+ },
126
+ rules: recommendedRules
127
127
  },
128
- supportsAutofix: true
129
- },
130
- // This processor is used for ESLint FlatConfig,
131
- // once we roll out FlatConfig, we can remove the above processor
132
- 'package-json-processor-for-flat-config': {
133
- preprocess: function preprocess(source) {
134
- // augment the json into a js file
135
- return [jsonPrefixForFlatConfig + source.trim()];
128
+ jira: {
129
+ plugins: ['@atlaskit/platform', '@compiled'],
130
+ rules: jiraRules
136
131
  },
137
- postprocess: function postprocess(messages) {
138
- return messages[0].map(function (message) {
139
- var fix = message.fix;
140
- if (!fix) {
141
- return message;
132
+ 'jira/flat': {
133
+ plugins: {
134
+ get '@atlaskit/platform'() {
135
+ return plugin;
136
+ },
137
+ // @ts-expect-error there's an issue with the types for @compiled/eslint-plugin ('no-css-prop-without-css-function' specifically)
138
+ '@compiled': {
139
+ meta: _eslintPlugin.default.meta,
140
+ rules: _eslintPlugin.default.rules
142
141
  }
143
- var offset = jsonPrefixForFlatConfig.length;
144
- return _objectSpread(_objectSpread({}, message), {}, {
145
- fix: _objectSpread(_objectSpread({}, fix), {}, {
146
- range: [fix.range[0] - offset, fix.range[1] - offset]
147
- })
142
+ },
143
+ rules: jiraRules
144
+ }
145
+ },
146
+ processors: {
147
+ 'package-json-processor': {
148
+ preprocess: function preprocess(source) {
149
+ // augment the json into a js file
150
+ return [jsonPrefix + source.trim()];
151
+ },
152
+ postprocess: function postprocess(messages) {
153
+ return messages[0].map(function (message) {
154
+ var fix = message.fix;
155
+ if (!fix) {
156
+ return message;
157
+ }
158
+ var offset = jsonPrefix.length;
159
+ return _objectSpread(_objectSpread({}, message), {}, {
160
+ fix: _objectSpread(_objectSpread({}, fix), {}, {
161
+ range: [fix.range[0] - offset, fix.range[1] - offset]
162
+ })
163
+ });
148
164
  });
149
- });
165
+ },
166
+ supportsAutofix: true
150
167
  },
151
- supportsAutofix: true
168
+ // This processor is used for ESLint FlatConfig,
169
+ // once we roll out FlatConfig, we can remove the above processor
170
+ 'package-json-processor-for-flat-config': {
171
+ preprocess: function preprocess(source) {
172
+ // augment the json into a js file
173
+ return [jsonPrefixForFlatConfig + source.trim()];
174
+ },
175
+ postprocess: function postprocess(messages) {
176
+ return messages[0].map(function (message) {
177
+ var fix = message.fix;
178
+ if (!fix) {
179
+ return message;
180
+ }
181
+ var offset = jsonPrefixForFlatConfig.length;
182
+ return _objectSpread(_objectSpread({}, message), {}, {
183
+ fix: _objectSpread(_objectSpread({}, fix), {}, {
184
+ range: [fix.range[0] - offset, fix.range[1] - offset]
185
+ })
186
+ });
187
+ });
188
+ },
189
+ supportsAutofix: true
190
+ }
152
191
  }
153
- };
192
+ };
193
+ var configs = exports.configs = plugin.configs;
194
+ var processors = exports.processors = plugin.processors;
195
+ var _default = exports.default = plugin;
@@ -30,11 +30,12 @@ var parseTemplateLiteral = function parseTemplateLiteral(templateLiteral, contex
30
30
  if (i < quasis.length) {
31
31
  var cookedQuasi = quasis[i].value.cooked;
32
32
  if (cookedQuasi) {
33
- var splitQuasi = cookedQuasi.split(' ').filter(function (str) {
34
- return str.trim().length > 0;
35
- });
36
- splitQuasi.forEach(function (str) {
37
- propertyValues.push(isNaN(Number(str)) ? "'".concat(str, "'") : str);
33
+ var splitQuasis = cookedQuasi.split(' ');
34
+ splitQuasis.forEach(function (str) {
35
+ str = str.trim().replace("'", '');
36
+ if (str.length > 0) {
37
+ propertyValues.push(isNaN(Number(str)) ? "'".concat(str, "'") : str);
38
+ }
38
39
  });
39
40
  }
40
41
  }
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line import/no-extraneous-dependencies
2
-
2
+ import compiledPlugin from '@compiled/eslint-plugin';
3
3
  import ensureFeatureFlagRegistration from './rules/ensure-feature-flag-registration';
4
4
  import noPreAndPostInstallScripts from './rules/no-pre-post-installs';
5
5
  import ensureTestRunnerArguments from './rules/ensure-test-runner-arguments';
@@ -26,7 +26,8 @@ import useEntrypointsInExamples from './rules/use-entrypoints-in-examples';
26
26
  import useRecommendedUtils from './rules/feature-gating/use-recommended-utils';
27
27
  import expandBackgroundShorthand from './rules/compiled/expand-background-shorthand';
28
28
  import expandSpacingShorthand from './rules/compiled/expand-spacing-shorthand';
29
- export const rules = {
29
+ const packageJson = require('@atlaskit/eslint-plugin-platform/package.json');
30
+ const rules = {
30
31
  'ensure-feature-flag-registration': ensureFeatureFlagRegistration,
31
32
  'ensure-feature-flag-prefix': ensureFeatureFlagPrefix,
32
33
  'ensure-test-runner-arguments': ensureTestRunnerArguments,
@@ -71,86 +72,127 @@ const commonConfig = {
71
72
  runtime: 'classic'
72
73
  }]
73
74
  };
74
- export const configs = {
75
- recommended: {
76
- plugins: ['@atlaskit/platform', '@compiled'],
77
- rules: {
78
- ...commonConfig,
79
- // See platform/packages/platform/eslint-plugin/src/rules/feature-gating/README.md
80
- // These rules are specific to `platform` and seem a WIP; jira and confluence currently have their own rules
81
- '@atlaskit/platform/no-module-level-eval': 'error',
82
- '@atlaskit/platform/static-feature-flags': 'error',
83
- '@atlaskit/platform/no-preconditioning': 'error',
84
- '@atlaskit/platform/inline-usage': 'error',
85
- '@atlaskit/platform/prefer-fg': 'error',
86
- '@atlaskit/platform/no-alias': 'error',
87
- // end: feature-gating rules
88
- '@atlaskit/platform/ensure-feature-flag-registration': 'error',
89
- '@atlaskit/platform/ensure-feature-flag-prefix': ['warn', {
90
- allowedPrefixes: ['platform.', 'platform_']
91
- }]
92
- }
93
- },
94
- jira: {
95
- plugins: ['@atlaskit/platform', '@compiled'],
96
- rules: {
97
- ...commonConfig
98
- }
99
- }
75
+ const recommendedRules = {
76
+ ...commonConfig,
77
+ // See platform/packages/platform/eslint-plugin/src/rules/feature-gating/README.md
78
+ // These rules are specific to `platform` and seem a WIP; jira and confluence currently have their own rules
79
+ '@atlaskit/platform/no-module-level-eval': 'error',
80
+ '@atlaskit/platform/static-feature-flags': 'error',
81
+ '@atlaskit/platform/no-preconditioning': 'error',
82
+ '@atlaskit/platform/inline-usage': 'error',
83
+ '@atlaskit/platform/prefer-fg': 'error',
84
+ '@atlaskit/platform/no-alias': 'error',
85
+ // end: feature-gating rules
86
+ '@atlaskit/platform/ensure-feature-flag-registration': 'error',
87
+ '@atlaskit/platform/ensure-feature-flag-prefix': ['warn', {
88
+ allowedPrefixes: ['platform.', 'platform_']
89
+ }]
100
90
  };
91
+ const jiraRules = commonConfig;
101
92
  const jsonPrefix = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, @typescript-eslint/semi, no-template-curly-in-string */ module.exports = ';
102
93
  const jsonPrefixForFlatConfig = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, no-template-curly-in-string */ module.exports = ';
103
- export const processors = {
104
- 'package-json-processor': {
105
- preprocess: source => {
106
- // augment the json into a js file
107
- return [jsonPrefix + source.trim()];
94
+ const {
95
+ name,
96
+ version
97
+ } = packageJson;
98
+ const plugin = {
99
+ meta: {
100
+ name,
101
+ version
102
+ },
103
+ rules,
104
+ configs: {
105
+ recommended: {
106
+ plugins: ['@atlaskit/platform', '@compiled'],
107
+ rules: recommendedRules
108
108
  },
109
- postprocess: messages => {
110
- return messages[0].map(message => {
111
- const {
112
- fix
113
- } = message;
114
- if (!fix) {
115
- return message;
109
+ 'recommended/flat': {
110
+ plugins: {
111
+ get '@atlaskit/platform'() {
112
+ return plugin;
113
+ },
114
+ // @ts-expect-error there's an issue with the types for @compiled/eslint-plugin ('no-css-prop-without-css-function' specifically)
115
+ '@compiled': {
116
+ meta: compiledPlugin.meta,
117
+ rules: compiledPlugin.rules
116
118
  }
117
- const offset = jsonPrefix.length;
118
- return {
119
- ...message,
120
- fix: {
121
- ...fix,
122
- range: [fix.range[0] - offset, fix.range[1] - offset]
123
- }
124
- };
125
- });
119
+ },
120
+ rules: recommendedRules
126
121
  },
127
- supportsAutofix: true
128
- },
129
- // This processor is used for ESLint FlatConfig,
130
- // once we roll out FlatConfig, we can remove the above processor
131
- 'package-json-processor-for-flat-config': {
132
- preprocess: source => {
133
- // augment the json into a js file
134
- return [jsonPrefixForFlatConfig + source.trim()];
122
+ jira: {
123
+ plugins: ['@atlaskit/platform', '@compiled'],
124
+ rules: jiraRules
135
125
  },
136
- postprocess: messages => {
137
- return messages[0].map(message => {
138
- const {
139
- fix
140
- } = message;
141
- if (!fix) {
142
- return message;
126
+ 'jira/flat': {
127
+ plugins: {
128
+ get '@atlaskit/platform'() {
129
+ return plugin;
130
+ },
131
+ // @ts-expect-error there's an issue with the types for @compiled/eslint-plugin ('no-css-prop-without-css-function' specifically)
132
+ '@compiled': {
133
+ meta: compiledPlugin.meta,
134
+ rules: compiledPlugin.rules
143
135
  }
144
- const offset = jsonPrefixForFlatConfig.length;
145
- return {
146
- ...message,
147
- fix: {
148
- ...fix,
149
- range: [fix.range[0] - offset, fix.range[1] - offset]
136
+ },
137
+ rules: jiraRules
138
+ }
139
+ },
140
+ processors: {
141
+ 'package-json-processor': {
142
+ preprocess: source => {
143
+ // augment the json into a js file
144
+ return [jsonPrefix + source.trim()];
145
+ },
146
+ postprocess: messages => {
147
+ return messages[0].map(message => {
148
+ const {
149
+ fix
150
+ } = message;
151
+ if (!fix) {
152
+ return message;
150
153
  }
151
- };
152
- });
154
+ const offset = jsonPrefix.length;
155
+ return {
156
+ ...message,
157
+ fix: {
158
+ ...fix,
159
+ range: [fix.range[0] - offset, fix.range[1] - offset]
160
+ }
161
+ };
162
+ });
163
+ },
164
+ supportsAutofix: true
153
165
  },
154
- supportsAutofix: true
166
+ // This processor is used for ESLint FlatConfig,
167
+ // once we roll out FlatConfig, we can remove the above processor
168
+ 'package-json-processor-for-flat-config': {
169
+ preprocess: source => {
170
+ // augment the json into a js file
171
+ return [jsonPrefixForFlatConfig + source.trim()];
172
+ },
173
+ postprocess: messages => {
174
+ return messages[0].map(message => {
175
+ const {
176
+ fix
177
+ } = message;
178
+ if (!fix) {
179
+ return message;
180
+ }
181
+ const offset = jsonPrefixForFlatConfig.length;
182
+ return {
183
+ ...message,
184
+ fix: {
185
+ ...fix,
186
+ range: [fix.range[0] - offset, fix.range[1] - offset]
187
+ }
188
+ };
189
+ });
190
+ },
191
+ supportsAutofix: true
192
+ }
155
193
  }
156
- };
194
+ };
195
+ const configs = plugin.configs;
196
+ const processors = plugin.processors;
197
+ export { configs, plugin, processors, rules };
198
+ export default plugin;
@@ -19,9 +19,12 @@ const parseTemplateLiteral = (templateLiteral, context) => {
19
19
  if (i < quasis.length) {
20
20
  const cookedQuasi = quasis[i].value.cooked;
21
21
  if (cookedQuasi) {
22
- const splitQuasi = cookedQuasi.split(' ').filter(str => str.trim().length > 0);
23
- splitQuasi.forEach(str => {
24
- propertyValues.push(isNaN(Number(str)) ? `'${str}'` : str);
22
+ const splitQuasis = cookedQuasi.split(' ');
23
+ splitQuasis.forEach(str => {
24
+ str = str.trim().replace("'", '');
25
+ if (str.length > 0) {
26
+ propertyValues.push(isNaN(Number(str)) ? `'${str}'` : str);
27
+ }
25
28
  });
26
29
  }
27
30
  }