@sabzidev/eslint-rules 1.0.6 → 1.0.8
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 +11 -11
- package/dist/index.js +63 -42
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -161,17 +161,17 @@ export default config;
|
|
|
161
161
|
|
|
162
162
|
## 📋 Available Rules
|
|
163
163
|
|
|
164
|
-
| Rule | Description
|
|
165
|
-
| :--------------------------------------- |
|
|
166
|
-
| `merge-duplicate-id-and-classname-props` | Merges duplicate id and className props.
|
|
167
|
-
| `merge-exports` | Merges or organizes export declarations.
|
|
168
|
-
| `no-invalid-id-and-classname-value` | Detects invalid id and className values.
|
|
169
|
-
| `no-useless-empty-type` | Detects unnecessary empty types.
|
|
170
|
-
| `no-useless-template-literal` | Detects unnecessary template literals.
|
|
171
|
-
| `padding-before-jump-statement` | Enforces padding before jump statements.
|
|
172
|
-
| `sort-comments` | Sorts comments.
|
|
173
|
-
| `sort-jsx-props` | Sorts JSX props.
|
|
174
|
-
| `sort-
|
|
164
|
+
| Rule | Description |
|
|
165
|
+
| :--------------------------------------- | :------------------------------------------------------------------------- |
|
|
166
|
+
| `merge-duplicate-id-and-classname-props` | Merges duplicate id and className props. |
|
|
167
|
+
| `merge-exports` | Merges or organizes export declarations. |
|
|
168
|
+
| `no-invalid-id-and-classname-value` | Detects invalid id and className values. |
|
|
169
|
+
| `no-useless-empty-type` | Detects unnecessary empty types. |
|
|
170
|
+
| `no-useless-template-literal` | Detects unnecessary template literals. |
|
|
171
|
+
| `padding-before-jump-statement` | Enforces padding before jump statements. |
|
|
172
|
+
| `sort-comments` | Sorts comments. |
|
|
173
|
+
| `sort-jsx-props` | Sorts JSX props. |
|
|
174
|
+
| `sort-props` | Sorts object properties, function parameters, and TypeScript type members. |
|
|
175
175
|
|
|
176
176
|
---
|
|
177
177
|
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var e = {
|
|
|
17
17
|
},
|
|
18
18
|
license: "MIT",
|
|
19
19
|
author: "Abolfazl Sabzmohammadi <SabziDev@gmail.com> (https://Sabzi.Dev)",
|
|
20
|
-
version: "1.0.
|
|
20
|
+
version: "1.0.8",
|
|
21
21
|
type: "module",
|
|
22
22
|
main: "./dist/index.js",
|
|
23
23
|
exports: "./dist/index.js",
|
|
@@ -421,8 +421,10 @@ var e = {
|
|
|
421
421
|
wrongOrder: "Object properties should be ordered!",
|
|
422
422
|
wrongDestructure: "Destructured properties should be ordered!",
|
|
423
423
|
wrongParams: "Function parameters should be ordered!",
|
|
424
|
+
wrongCallArguments: "Function call arguments should be ordered!",
|
|
424
425
|
wrongTypeProperties: "Type properties should be ordered!"
|
|
425
|
-
}
|
|
426
|
+
},
|
|
427
|
+
schema: []
|
|
426
428
|
},
|
|
427
429
|
create(e) {
|
|
428
430
|
let { sourceCode: t } = e, n = new Set(l), r = (e) => /^on[A-Z]/.test(e), i = (e) => {
|
|
@@ -470,42 +472,60 @@ var e = {
|
|
|
470
472
|
if (!r || r.length <= 1) return;
|
|
471
473
|
let i = d(r);
|
|
472
474
|
g(e, r, i, n, (e) => e.map((e) => t.getText(e)).join(", "));
|
|
473
|
-
}, v = (
|
|
474
|
-
let
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
if (!p(
|
|
499
|
-
let
|
|
475
|
+
}, v = (e) => {
|
|
476
|
+
let t = l.indexOf(e);
|
|
477
|
+
return t === -1 ? r(e) ? {
|
|
478
|
+
category: 2,
|
|
479
|
+
priority: i(e)
|
|
480
|
+
} : e === "className" ? {
|
|
481
|
+
category: 3,
|
|
482
|
+
priority: 0
|
|
483
|
+
} : {
|
|
484
|
+
category: e === "style" ? 4 : 1,
|
|
485
|
+
priority: 0
|
|
486
|
+
} : {
|
|
487
|
+
category: 0,
|
|
488
|
+
priority: t
|
|
489
|
+
};
|
|
490
|
+
}, y = (e) => e.map((e, t) => ({
|
|
491
|
+
item: e,
|
|
492
|
+
index: t,
|
|
493
|
+
...v(e.name)
|
|
494
|
+
})).sort((e, t) => e.category === t.category ? e.priority === t.priority ? e.index - t.index : e.priority - t.priority : e.category - t.category).map(({ item: e }) => e), b = (n) => {
|
|
495
|
+
let { params: r } = n;
|
|
496
|
+
if (!r || r.length === 0) return;
|
|
497
|
+
for (let e of r) e.type === "ObjectPattern" && _(e, "wrongParams");
|
|
498
|
+
if (r.length <= 1 || r.some((e) => e.type !== "Identifier")) return;
|
|
499
|
+
let i = y(r);
|
|
500
|
+
if (!p(r, i)) return;
|
|
501
|
+
let a = r[0], o = r.at(-1);
|
|
500
502
|
e.report({
|
|
501
503
|
node: n,
|
|
502
504
|
messageId: "wrongParams",
|
|
503
505
|
fix(e) {
|
|
504
|
-
let n =
|
|
505
|
-
return e.replaceTextRange([
|
|
506
|
+
let n = i.map((e) => t.getText(e)).join(", ");
|
|
507
|
+
return e.replaceTextRange([a.range[0], o.range[1]], n);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
}, x = (e) => e.type === "Identifier" ? e.name : e.type === "Literal" || e.type === "StringLiteral" || e.type === "NumericLiteral" ? String(e.value) : null, S = (n) => {
|
|
511
|
+
let { arguments: r } = n;
|
|
512
|
+
if (r.length <= 1 || r.some((e) => e.type === "SpreadElement" || x(e) === null)) return;
|
|
513
|
+
let i = r.map((e, t) => ({
|
|
514
|
+
argument: e,
|
|
515
|
+
index: t,
|
|
516
|
+
...v(x(e))
|
|
517
|
+
})).sort((e, t) => e.category === t.category ? e.priority === t.priority ? e.index - t.index : e.priority - t.priority : e.category - t.category).map(({ argument: e }) => e);
|
|
518
|
+
if (!p(r, i)) return;
|
|
519
|
+
let a = r[0], o = r.at(-1);
|
|
520
|
+
e.report({
|
|
521
|
+
node: n,
|
|
522
|
+
messageId: "wrongCallArguments",
|
|
523
|
+
fix(e) {
|
|
524
|
+
let n = i.map((e) => t.getText(e)).join(", ");
|
|
525
|
+
return e.replaceTextRange([a.range[0], o.range[1]], n);
|
|
506
526
|
}
|
|
507
527
|
});
|
|
508
|
-
},
|
|
528
|
+
}, C = (e) => {
|
|
509
529
|
let t = e.body ?? e.members;
|
|
510
530
|
if (!t || t.length <= 1) return;
|
|
511
531
|
let n = f(t);
|
|
@@ -527,16 +547,17 @@ var e = {
|
|
|
527
547
|
ObjectPattern(e) {
|
|
528
548
|
_(e, "wrongDestructure");
|
|
529
549
|
},
|
|
530
|
-
TSTypeLiteral:
|
|
531
|
-
TSInterfaceBody:
|
|
532
|
-
FunctionDeclaration:
|
|
533
|
-
FunctionExpression:
|
|
534
|
-
ArrowFunctionExpression:
|
|
535
|
-
TSDeclareFunction:
|
|
536
|
-
TSFunctionType:
|
|
537
|
-
TSCallSignatureDeclaration:
|
|
538
|
-
TSConstructSignatureDeclaration:
|
|
539
|
-
TSMethodSignature:
|
|
550
|
+
TSTypeLiteral: C,
|
|
551
|
+
TSInterfaceBody: C,
|
|
552
|
+
FunctionDeclaration: b,
|
|
553
|
+
FunctionExpression: b,
|
|
554
|
+
ArrowFunctionExpression: b,
|
|
555
|
+
TSDeclareFunction: b,
|
|
556
|
+
TSFunctionType: b,
|
|
557
|
+
TSCallSignatureDeclaration: b,
|
|
558
|
+
TSConstructSignatureDeclaration: b,
|
|
559
|
+
TSMethodSignature: b,
|
|
560
|
+
CallExpression: S
|
|
540
561
|
};
|
|
541
562
|
}
|
|
542
563
|
}
|
package/package.json
CHANGED