@atlaskit/eslint-plugin-platform 1.1.0 → 2.0.1

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,20 @@
1
1
  # @atlaskit/eslint-plugin-platform
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2034d96c50c40`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2034d96c50c40) -
8
+ fixed backwards compatibility with older versions of eslint
9
+
10
+ ## 2.0.0
11
+
12
+ ### Major Changes
13
+
14
+ - [#176646](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/176646)
15
+ [`9612cd921a885`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9612cd921a885) -
16
+ ESlint rule for expand background shorthand with color token
17
+
3
18
  ## 1.1.0
4
19
 
5
20
  ### Minor Changes
package/dist/cjs/index.js CHANGED
@@ -69,7 +69,7 @@ var commonConfig = {
69
69
  '@atlaskit/platform/no-module-level-eval-nav4': 'error',
70
70
  // Compiled: rules that are not included via `@compiled/recommended
71
71
  '@atlaskit/platform/expand-border-shorthand': 'error',
72
- '@atlaskit/platform/expand-background-shorthand': 'warn',
72
+ '@atlaskit/platform/expand-background-shorthand': 'error',
73
73
  '@compiled/jsx-pragma': ['error', {
74
74
  importSources: ['@atlaskit/css'],
75
75
  onlyRunIfImportingCompiled: true,
@@ -28,6 +28,6 @@ var getSourceCode = function getSourceCode(context) {
28
28
  * @param node - The node to get the scope for
29
29
  */
30
30
  var getScope = exports.getScope = function getScope(context, node) {
31
- var _getSourceCode$getSco, _getSourceCode;
32
- return (_getSourceCode$getSco = (_getSourceCode = getSourceCode(context)) === null || _getSourceCode === void 0 ? void 0 : _getSourceCode.getScope(node)) !== null && _getSourceCode$getSco !== void 0 ? _getSourceCode$getSco : context.getScope();
31
+ var _getSourceCode$getSco, _getSourceCode, _getSourceCode$getSco2;
32
+ return (_getSourceCode$getSco = (_getSourceCode = getSourceCode(context)) === null || _getSourceCode === void 0 || (_getSourceCode$getSco2 = _getSourceCode.getScope) === null || _getSourceCode$getSco2 === void 0 ? void 0 : _getSourceCode$getSco2.call(_getSourceCode, node)) !== null && _getSourceCode$getSco !== void 0 ? _getSourceCode$getSco : context.getScope();
33
33
  };
@@ -61,7 +61,7 @@ const commonConfig = {
61
61
  '@atlaskit/platform/no-module-level-eval-nav4': 'error',
62
62
  // Compiled: rules that are not included via `@compiled/recommended
63
63
  '@atlaskit/platform/expand-border-shorthand': 'error',
64
- '@atlaskit/platform/expand-background-shorthand': 'warn',
64
+ '@atlaskit/platform/expand-background-shorthand': 'error',
65
65
  '@compiled/jsx-pragma': ['error', {
66
66
  importSources: ['@atlaskit/css'],
67
67
  onlyRunIfImportingCompiled: true,
@@ -22,6 +22,6 @@ const getSourceCode = context => {
22
22
  * @param node - The node to get the scope for
23
23
  */
24
24
  export const getScope = (context, node) => {
25
- var _getSourceCode$getSco, _getSourceCode;
26
- return (_getSourceCode$getSco = (_getSourceCode = getSourceCode(context)) === null || _getSourceCode === void 0 ? void 0 : _getSourceCode.getScope(node)) !== null && _getSourceCode$getSco !== void 0 ? _getSourceCode$getSco : context.getScope();
25
+ var _getSourceCode$getSco, _getSourceCode, _getSourceCode$getSco2;
26
+ return (_getSourceCode$getSco = (_getSourceCode = getSourceCode(context)) === null || _getSourceCode === void 0 ? void 0 : (_getSourceCode$getSco2 = _getSourceCode.getScope) === null || _getSourceCode$getSco2 === void 0 ? void 0 : _getSourceCode$getSco2.call(_getSourceCode, node)) !== null && _getSourceCode$getSco !== void 0 ? _getSourceCode$getSco : context.getScope();
27
27
  };
package/dist/esm/index.js CHANGED
@@ -64,7 +64,7 @@ var commonConfig = {
64
64
  '@atlaskit/platform/no-module-level-eval-nav4': 'error',
65
65
  // Compiled: rules that are not included via `@compiled/recommended
66
66
  '@atlaskit/platform/expand-border-shorthand': 'error',
67
- '@atlaskit/platform/expand-background-shorthand': 'warn',
67
+ '@atlaskit/platform/expand-background-shorthand': 'error',
68
68
  '@compiled/jsx-pragma': ['error', {
69
69
  importSources: ['@atlaskit/css'],
70
70
  onlyRunIfImportingCompiled: true,
@@ -22,6 +22,6 @@ var getSourceCode = function getSourceCode(context) {
22
22
  * @param node - The node to get the scope for
23
23
  */
24
24
  export var getScope = function getScope(context, node) {
25
- var _getSourceCode$getSco, _getSourceCode;
26
- return (_getSourceCode$getSco = (_getSourceCode = getSourceCode(context)) === null || _getSourceCode === void 0 ? void 0 : _getSourceCode.getScope(node)) !== null && _getSourceCode$getSco !== void 0 ? _getSourceCode$getSco : context.getScope();
25
+ var _getSourceCode$getSco, _getSourceCode, _getSourceCode$getSco2;
26
+ return (_getSourceCode$getSco = (_getSourceCode = getSourceCode(context)) === null || _getSourceCode === void 0 || (_getSourceCode$getSco2 = _getSourceCode.getScope) === null || _getSourceCode$getSco2 === void 0 ? void 0 : _getSourceCode$getSco2.call(_getSourceCode, node)) !== null && _getSourceCode$getSco !== void 0 ? _getSourceCode$getSco : context.getScope();
27
27
  };
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": "1.1.0",
4
+ "version": "2.0.1",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "atlassian": {
7
7
  "team": "Build Infra",
package/src/index.tsx CHANGED
@@ -63,7 +63,7 @@ const commonConfig = {
63
63
  '@atlaskit/platform/no-module-level-eval-nav4': 'error',
64
64
  // Compiled: rules that are not included via `@compiled/recommended
65
65
  '@atlaskit/platform/expand-border-shorthand': 'error',
66
- '@atlaskit/platform/expand-background-shorthand': 'warn',
66
+ '@atlaskit/platform/expand-background-shorthand': 'error',
67
67
  '@compiled/jsx-pragma': [
68
68
  'error',
69
69
  {
@@ -0,0 +1,64 @@
1
+ import type { Rule, Scope, SourceCode } from 'eslint';
2
+ import type { Node } from 'estree';
3
+
4
+ import { getScope } from '../context-compat';
5
+
6
+ describe('context-compat', () => {
7
+ describe('getScope', () => {
8
+ let context: Rule.RuleContext;
9
+ let node: Node;
10
+ let sourceCode: SourceCode;
11
+ let scope: Scope.Scope;
12
+
13
+ beforeEach(() => {
14
+ node = {} as Node;
15
+ scope = {} as Scope.Scope;
16
+ sourceCode = {
17
+ getScope: jest.fn().mockReturnValue(scope),
18
+ } as unknown as SourceCode;
19
+ });
20
+
21
+ it('should return scope from context.sourceCode.getScope if available', () => {
22
+ context = {
23
+ sourceCode,
24
+ } as unknown as Rule.RuleContext;
25
+
26
+ const result = getScope(context, node);
27
+ expect(result).toBe(scope);
28
+ expect(sourceCode.getScope).toHaveBeenCalledWith(node);
29
+ });
30
+
31
+ it('should return scope from context.getSourceCode().getScope if context.sourceCode is not available', () => {
32
+ context = {
33
+ getSourceCode: jest.fn().mockReturnValue(sourceCode),
34
+ } as unknown as Rule.RuleContext;
35
+
36
+ const result = getScope(context, node);
37
+ expect(result).toBe(scope);
38
+ expect(context.getSourceCode).toHaveBeenCalled();
39
+ expect(sourceCode.getScope).toHaveBeenCalledWith(node);
40
+ });
41
+
42
+ it('should return scope from context.getScope if neither context.sourceCode nor context.getSourceCode().getScope is available', () => {
43
+ context = {
44
+ getSourceCode: jest.fn().mockReturnValue({}),
45
+ getScope: jest.fn().mockReturnValue(scope),
46
+ } as unknown as Rule.RuleContext;
47
+
48
+ const result = getScope(context, node);
49
+ expect(result).toBe(scope);
50
+ expect(context.getScope).toHaveBeenCalled();
51
+ });
52
+
53
+ it('should return scope from context.getScope if context.sourceCode does not have getScope', () => {
54
+ context = {
55
+ sourceCode: {},
56
+ getScope: jest.fn().mockReturnValue(scope),
57
+ } as unknown as Rule.RuleContext;
58
+
59
+ const result = getScope(context, node);
60
+ expect(result).toBe(scope);
61
+ expect(context.getScope).toHaveBeenCalled();
62
+ });
63
+ });
64
+ });
@@ -24,5 +24,5 @@ const getSourceCode = (context: Rule.RuleContext): SourceCode => {
24
24
  * @param node - The node to get the scope for
25
25
  */
26
26
  export const getScope = (context: Rule.RuleContext, node: Node): Scope.Scope => {
27
- return getSourceCode(context)?.getScope(node) ?? context.getScope();
27
+ return getSourceCode(context)?.getScope?.(node) ?? context.getScope();
28
28
  };