@e18e/eslint-plugin 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -63,6 +63,18 @@ If you're using oxlint, you can enable the e18e plugin by adding it to your `.ox
63
63
  }
64
64
  ```
65
65
 
66
+ You can enable the recommended configuration by copying the rules from each of the ESLint configuration files into your `.oxlintrc.json` file.
67
+
68
+ - [modernization configuration](./src/configs/modernization.ts)
69
+ - [module replacements configuration](./src/configs/module-replacements.ts)
70
+ - [performance improvements configuration](./src/configs/performance-improvements.ts)
71
+
72
+ Copying these rules into your `rules` object will achieve the same effect as using the recommended configuration in ESLint.
73
+
74
+ > [!NOTE]
75
+ > Our type-aware rules depend on TypeScript ESLint's parser, which means they
76
+ > will not work with oxlint at this time.
77
+
66
78
  ## Rules
67
79
 
68
80
  **Legend:**
@@ -42,6 +42,12 @@ export const preferArrayAt = {
42
42
  if (arrayText !== lengthArrayText) {
43
43
  return;
44
44
  }
45
+ const parent = node.parent;
46
+ if (parent &&
47
+ parent.type === 'AssignmentExpression' &&
48
+ parent.left === node) {
49
+ return;
50
+ }
45
51
  context.report({
46
52
  node,
47
53
  messageId: 'preferAt',
@@ -47,9 +47,13 @@ export const preferSpreadSyntax = {
47
47
  node.callee.property.type === 'Identifier' &&
48
48
  node.callee.property.name === 'from' &&
49
49
  node.arguments.length === 1) {
50
- const iterableText = sourceCode.getText(node.arguments[0]);
51
- replacement = `[...${iterableText}]`;
52
- messageId = 'preferSpreadArrayFrom';
50
+ const firstArg = node.arguments[0];
51
+ if (firstArg.type !== 'SpreadElement' &&
52
+ firstArg.type !== 'ObjectExpression') {
53
+ const iterableText = sourceCode.getText(firstArg);
54
+ replacement = `[...${iterableText}]`;
55
+ messageId = 'preferSpreadArrayFrom';
56
+ }
53
57
  }
54
58
  // Object.assign({...}, ...)
55
59
  else if (node.callee.object.type === 'Identifier' &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e18e/eslint-plugin",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "The official e18e ESLint plugin for modernizing code and improving performance.",
5
5
  "keywords": [
6
6
  "eslint",