@croct/eslint-plugin 0.4.0 → 0.5.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.
@@ -75,12 +75,6 @@ export declare const configs: {
75
75
  };
76
76
  })[];
77
77
  };
78
- overrides: {
79
- files: string[];
80
- rules: {
81
- 'sort-keys-fix/sort-keys-fix': string;
82
- };
83
- }[];
84
78
  };
85
79
  typescript: {
86
80
  extends: string[];
@@ -151,9 +145,6 @@ export declare const configs: {
151
145
  })[];
152
146
  'no-undef': string;
153
147
  '@typescript-eslint/no-namespace': string;
154
- '@typescript-eslint/no-redeclare': (string | {
155
- ignoreDeclarationMerge: boolean;
156
- })[];
157
148
  'no-new-object'?: undefined;
158
149
  };
159
150
  plugins?: undefined;
@@ -192,7 +183,6 @@ export declare const configs: {
192
183
  '@typescript-eslint/member-delimiter-style'?: undefined;
193
184
  'no-undef'?: undefined;
194
185
  '@typescript-eslint/no-namespace'?: undefined;
195
- '@typescript-eslint/no-redeclare'?: undefined;
196
186
  };
197
187
  env: {
198
188
  jest: boolean;
@@ -61,10 +61,4 @@ export declare const react: {
61
61
  };
62
62
  })[];
63
63
  };
64
- overrides: {
65
- files: string[];
66
- rules: {
67
- 'sort-keys-fix/sort-keys-fix': string;
68
- };
69
- }[];
70
64
  };
package/configs/react.js CHANGED
@@ -17,7 +17,6 @@ exports.react = {
17
17
  'testing-library',
18
18
  'jest-dom',
19
19
  '@croct',
20
- 'sort-keys-fix',
21
20
  ],
22
21
  rules: {
23
22
  '@croct/jsx-attribute-spacing': 'error',
@@ -125,12 +124,4 @@ exports.react = {
125
124
  },
126
125
  ],
127
126
  },
128
- overrides: [
129
- {
130
- files: ['**/styles.ts'],
131
- rules: {
132
- 'sort-keys-fix/sort-keys-fix': 'error',
133
- },
134
- },
135
- ],
136
127
  };
@@ -67,9 +67,6 @@ export declare const typescript: {
67
67
  })[];
68
68
  'no-undef': string;
69
69
  '@typescript-eslint/no-namespace': string;
70
- '@typescript-eslint/no-redeclare': (string | {
71
- ignoreDeclarationMerge: boolean;
72
- })[];
73
70
  'no-new-object'?: undefined;
74
71
  };
75
72
  plugins?: undefined;
@@ -108,7 +105,6 @@ export declare const typescript: {
108
105
  '@typescript-eslint/member-delimiter-style'?: undefined;
109
106
  'no-undef'?: undefined;
110
107
  '@typescript-eslint/no-namespace'?: undefined;
111
- '@typescript-eslint/no-redeclare'?: undefined;
112
108
  };
113
109
  env: {
114
110
  jest: boolean;
@@ -79,9 +79,6 @@ exports.typescript = {
79
79
  }],
80
80
  'no-undef': 'off',
81
81
  '@typescript-eslint/no-namespace': 'off',
82
- '@typescript-eslint/no-redeclare': ['error', {
83
- ignoreDeclarationMerge: true,
84
- }],
85
82
  },
86
83
  },
87
84
  {
package/index.d.ts CHANGED
@@ -104,12 +104,6 @@ declare const configuration: {
104
104
  };
105
105
  })[];
106
106
  };
107
- overrides: {
108
- files: string[];
109
- rules: {
110
- 'sort-keys-fix/sort-keys-fix': string;
111
- };
112
- }[];
113
107
  };
114
108
  typescript: {
115
109
  extends: string[];
@@ -180,9 +174,6 @@ declare const configuration: {
180
174
  })[];
181
175
  'no-undef': string;
182
176
  '@typescript-eslint/no-namespace': string;
183
- '@typescript-eslint/no-redeclare': (string | {
184
- ignoreDeclarationMerge: boolean;
185
- })[];
186
177
  'no-new-object'?: undefined;
187
178
  };
188
179
  plugins?: undefined;
@@ -221,7 +212,6 @@ declare const configuration: {
221
212
  '@typescript-eslint/member-delimiter-style'?: undefined;
222
213
  'no-undef'?: undefined;
223
214
  '@typescript-eslint/no-namespace'?: undefined;
224
- '@typescript-eslint/no-redeclare'?: undefined;
225
215
  };
226
216
  env: {
227
217
  jest: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@croct/eslint-plugin",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "ESLint rules and presets applied to all Croct JavaScript projects.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -63,7 +63,6 @@
63
63
  "eslint": "^8.8",
64
64
  "eslint-plugin-eslint-plugin": "^4.1.0",
65
65
  "eslint-plugin-self": "^1.2.1",
66
- "eslint-plugin-sort-keys-fix": "^1.1.2",
67
66
  "jest": "^27.5",
68
67
  "ts-jest": "^27.1",
69
68
  "typescript": "^4.5"
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.minChainedCallDepth = void 0;
4
+ /*
5
+ eslint-disable @typescript-eslint/no-non-null-assertion
6
+ --
7
+ Disable the rule to reduce the number of branches
8
+ */
9
+ const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
4
10
  const ast_utils_1 = require("@typescript-eslint/utils/dist/ast-utils");
5
11
  const createRule_1 = require("../createRule");
6
12
  exports.minChainedCallDepth = (0, createRule_1.createRule)({
@@ -39,13 +45,13 @@ exports.minChainedCallDepth = (0, createRule_1.createRule)({
39
45
  function getDepth(node) {
40
46
  let depth = 0;
41
47
  let currentNode = node;
42
- while (currentNode.type === 'CallExpression'
43
- || currentNode.type === 'MemberExpression') {
44
- if (currentNode.type === 'MemberExpression') {
48
+ while (currentNode.type === experimental_utils_1.AST_NODE_TYPES.CallExpression
49
+ || currentNode.type === experimental_utils_1.AST_NODE_TYPES.MemberExpression) {
50
+ if (currentNode.type === experimental_utils_1.AST_NODE_TYPES.MemberExpression) {
45
51
  currentNode = currentNode.object;
46
52
  depth += 1;
47
53
  }
48
- else if (currentNode.type === 'CallExpression') {
54
+ else if (currentNode.type === experimental_utils_1.AST_NODE_TYPES.CallExpression) {
49
55
  currentNode = currentNode.callee;
50
56
  }
51
57
  }
@@ -53,8 +59,8 @@ exports.minChainedCallDepth = (0, createRule_1.createRule)({
53
59
  }
54
60
  function check(node) {
55
61
  var _a, _b;
56
- // If the node is a member expression inside a call expression skip, this is to ensure
57
- // that we consider the correct line length of the result.
62
+ // If the node is a member expression inside a call/new expression skip,
63
+ // this is to ensure that we consider the correct line length of the result.
58
64
  //
59
65
  // Example:
60
66
  // ```ts
@@ -63,20 +69,28 @@ exports.minChainedCallDepth = (0, createRule_1.createRule)({
63
69
  // ```
64
70
  // The replacement of this input should be `foo.bar();`, which has 10 character.
65
71
  // Without this check it would consider the length up to `r`, which is 7.
66
- if (node.type === 'MemberExpression' && ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.type) === 'CallExpression') {
72
+ if (node.type === experimental_utils_1.AST_NODE_TYPES.MemberExpression
73
+ && ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.type) === experimental_utils_1.AST_NODE_TYPES.CallExpression) {
67
74
  return;
68
75
  }
69
- // If the node is a call expression we need to validate it's callee as a member
76
+ // If the node is a call/new expression we need to validate it's callee as a member
70
77
  // expression.
71
78
  // If the node itself is already a member expression, like the
72
79
  // `property` in `this.property.function()`, we validate the node directly.
73
- const callee = node.type === 'CallExpression' ? node.callee : node;
80
+ const callee = node.type === experimental_utils_1.AST_NODE_TYPES.CallExpression
81
+ ? node.callee
82
+ : node;
74
83
  if (
75
84
  // If the callee is not a member expression, we can skip.
76
85
  // For example, root level calls like `foo();`.
77
- callee.type !== 'MemberExpression'
86
+ callee.type !== experimental_utils_1.AST_NODE_TYPES.MemberExpression
78
87
  // If the callee is a computed member expression, like `foo[bar]()`, we can skip.
79
88
  || callee.computed
89
+ /* eslint-disable-next-line @typescript-eslint/ban-ts-comment --
90
+ * NewExpression is a possible callee object type
91
+ */
92
+ // @ts-ignore
93
+ || callee.object.type === experimental_utils_1.AST_NODE_TYPES.NewExpression
80
94
  // If the callee is already in the same line as it's object, we can skip.
81
95
  || callee.object.loc.end.line === callee.property.loc.start.line) {
82
96
  return;
@@ -93,7 +107,7 @@ exports.minChainedCallDepth = (0, createRule_1.createRule)({
93
107
  });
94
108
  const semicolon = sourceCode.getLastToken(node.parent, {
95
109
  filter: token => (token.loc.start.line === property.loc.start.line
96
- && token.type === 'Punctuator'
110
+ && token.type === experimental_utils_1.AST_TOKEN_TYPES.Punctuator
97
111
  && token.value === ';'),
98
112
  });
99
113
  const lineLength = callee.object.loc.end.column