@hero-design/eslint-plugin 8.44.0-alpha.0 → 9.0.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 ADDED
@@ -0,0 +1,13 @@
1
+ # @hero-design/eslint-plugin
2
+
3
+ ## 9.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#2563](https://github.com/Thinkei/hero-design/pull/2563) [`0254e47a8`](https://github.com/Thinkei/hero-design/commit/0254e47a838f0f431c3d72306b945247786ea7d1) Thanks [@luanlai2201](https://github.com/luanlai2201)! - [Internal] Remove eslint no-invalid-access-theme rule
8
+
9
+ ## 8.42.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [#2302](https://github.com/Thinkei/hero-design/pull/2302) [`2293190d1`](https://github.com/Thinkei/hero-design/commit/2293190d105fb97dc699e39990c3148f3509fafb) Thanks [@vinhphan-eh](https://github.com/vinhphan-eh)! - Upgrade expo sdk and react-native version
package/lib/index.js CHANGED
@@ -43,7 +43,6 @@ module.exports = {
43
43
  plugins: ['@hero-design'],
44
44
  extends: ['plugin:@hero-design/internalRn'],
45
45
  rules: {
46
- '@hero-design/no-invalid-theme-access': 'error',
47
46
  '@hero-design/not-recommended-import': [
48
47
  'warn',
49
48
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/eslint-plugin",
3
- "version": "8.44.0-alpha.0",
3
+ "version": "9.0.0",
4
4
  "description": "Hero Design's eslint plugin",
5
5
  "keywords": [
6
6
  "eslint",
@@ -25,8 +25,8 @@
25
25
  "eslint": "^8.10.0",
26
26
  "eslint-plugin-eslint-plugin": "^5.0.0",
27
27
  "eslint-plugin-node": "^11.1.0",
28
- "jest": "^29.6.2",
29
- "prettier-config-hd": "8.44.0-alpha.0"
28
+ "jest": "^29.2.1",
29
+ "prettier-config-hd": "8.42.4"
30
30
  },
31
31
  "engines": {
32
32
  "node": "^14.17.0 || ^16.0.0 || >= 18.0.0"
File without changes
@@ -1,97 +0,0 @@
1
- 'use strict';
2
-
3
- //------------------------------------------------------------------------------
4
- // Rule Definition
5
- //------------------------------------------------------------------------------
6
-
7
- const findPaths = (node, paths) => {
8
- if (node == null) {
9
- return paths;
10
- }
11
- const property = node.property;
12
- if (
13
- property != null &&
14
- property.type === 'Identifier' &&
15
- property.name != null
16
- ) {
17
- return findPaths(node.parent, [...paths, property.name]);
18
- }
19
- return paths;
20
- };
21
-
22
- const getError = (themePath) => {
23
- if (themePath == null || themePath === '') {
24
- return 'Invalid access to theming object';
25
- }
26
-
27
- if (themePath.startsWith('__hd__')) {
28
- return 'Invalid access to component level theming object.';
29
- }
30
-
31
- return undefined;
32
- };
33
-
34
- /** @type {import('eslint').Rule.RuleModule} */
35
- module.exports = {
36
- meta: {
37
- type: 'problem', // `problem`, `suggestion`, or `layout`
38
- docs: {
39
- description: 'Invalidate theming access',
40
- recommended: false,
41
- },
42
- fixable: null, // or "code" or "whitespace"
43
- schema: [
44
- {
45
- properties: {
46
- themeFile: { type: ['string'] },
47
- },
48
- },
49
- ],
50
- messages: {
51
- invalidThemeAccess: 'Invalid access to component level theming object.',
52
- },
53
- },
54
- create: function (context) {
55
- return {
56
- MemberExpression(node) {
57
- const object = node.object;
58
- if (object == null) {
59
- return;
60
- }
61
-
62
- if (object.type === 'Identifier' && object.name === 'theme') {
63
- const paths = findPaths(node, []);
64
- const themePath = paths.join('.');
65
- const error = getError(themePath);
66
- if (error != null) {
67
- context.report({
68
- node,
69
- messageId: 'invalidThemeAccess',
70
- });
71
- }
72
- return;
73
- }
74
-
75
- const property = node.property;
76
- if (
77
- property != null &&
78
- property.name === 'theme' &&
79
- object.type === 'Identifier' &&
80
- object.name === 'props'
81
- ) {
82
- // First element is theme, we don't need it
83
- const [, ...paths] = findPaths(node, []);
84
- const themePath = paths.join('.');
85
- const error = getError(themePath);
86
- if (error != null) {
87
- context.report({
88
- node,
89
- messageId: 'invalidThemeAccess',
90
- });
91
- }
92
- return;
93
- }
94
- },
95
- };
96
- },
97
- };
@@ -1,41 +0,0 @@
1
- 'use strict';
2
-
3
- //------------------------------------------------------------------------------
4
- // Requirements
5
- //------------------------------------------------------------------------------
6
-
7
- var rule = require('../../../lib/rules/no-invalid-theme-access'),
8
- RuleTester = require('eslint').RuleTester;
9
-
10
- //------------------------------------------------------------------------------
11
- // Tests
12
- //------------------------------------------------------------------------------
13
-
14
- var ruleTester = new RuleTester();
15
- ruleTester.run('no-invalid-theme-access', rule, {
16
- valid: [
17
- {
18
- code: 'theme.space.medium',
19
- },
20
- ],
21
- invalid: [
22
- {
23
- code: 'theme.__hd__.card.space.titlePadding',
24
- errors: [
25
- {
26
- type: 'MemberExpression',
27
- message: 'Invalid access to component level theming object.',
28
- },
29
- ],
30
- },
31
- {
32
- code: 'props.theme.__hd__.card.space.titlePadding',
33
- errors: [
34
- {
35
- type: 'MemberExpression',
36
- message: 'Invalid access to component level theming object.',
37
- },
38
- ],
39
- },
40
- ],
41
- });