@agilebot/eslint-plugin 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +93 -41
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
@@ -4,6 +4,8 @@ declare namespace _default {
|
|
4
4
|
namespace recommended {
|
5
5
|
export let plugins: string[];
|
6
6
|
let rules_1: {
|
7
|
+
'@agilebot/no-unnecessary-template-literals': string;
|
8
|
+
'@agilebot/no-async-array-methods': string;
|
7
9
|
'@agilebot/react-prefer-named-property-access': string;
|
8
10
|
'@agilebot/react-hook-use-ref': string;
|
9
11
|
'@agilebot/react-prefer-sx-prop': string;
|
@@ -12,7 +14,6 @@ declare namespace _default {
|
|
12
14
|
'@agilebot/tss-class-naming': string;
|
13
15
|
'@agilebot/import-enforce-icon-alias': string;
|
14
16
|
'@agilebot/import-monorepo': string;
|
15
|
-
'@agilebot/stylistic-no-unnecessary-template-literals': string;
|
16
17
|
};
|
17
18
|
export { rules_1 as rules };
|
18
19
|
export namespace settings {
|
package/dist/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @license @agilebot/eslint-plugin v0.3.
|
2
|
+
* @license @agilebot/eslint-plugin v0.3.3
|
3
3
|
*
|
4
4
|
* Copyright (c) Agilebot, Inc. and its affiliates.
|
5
5
|
*
|
@@ -766,6 +766,91 @@ var unusedClasses = {
|
|
766
766
|
}
|
767
767
|
};
|
768
768
|
|
769
|
+
var noAsyncArrayMethods = {
|
770
|
+
meta: {
|
771
|
+
docs: {
|
772
|
+
description:
|
773
|
+
'No async callback for Array methods forEach, map, filter, reduce, some, every, etc.',
|
774
|
+
category: 'Array',
|
775
|
+
recommended: true
|
776
|
+
},
|
777
|
+
fixable: undefined,
|
778
|
+
schema: []
|
779
|
+
},
|
780
|
+
create: function (context) {
|
781
|
+
return {
|
782
|
+
ExpressionStatement: function (node) {
|
783
|
+
const notAllowedArrayMethods = [
|
784
|
+
'forEach',
|
785
|
+
'filter',
|
786
|
+
'some',
|
787
|
+
'every',
|
788
|
+
'map',
|
789
|
+
'reduce',
|
790
|
+
'reduceRight',
|
791
|
+
'flatMap',
|
792
|
+
'find',
|
793
|
+
'findIndex',
|
794
|
+
'findLast',
|
795
|
+
'findLastIndex'
|
796
|
+
];
|
797
|
+
const { callee } = node.expression;
|
798
|
+
if (!callee || !callee.property || !callee.property.name) {
|
799
|
+
return;
|
800
|
+
}
|
801
|
+
if (notAllowedArrayMethods.includes(callee.property.name)) {
|
802
|
+
const functionArguments = node.expression.arguments.find(n => {
|
803
|
+
return ['ArrowFunctionExpression', 'FunctionExpression'].includes(
|
804
|
+
n.type
|
805
|
+
);
|
806
|
+
});
|
807
|
+
if (functionArguments && functionArguments.async) {
|
808
|
+
context.report({
|
809
|
+
node,
|
810
|
+
message: `No async function in method '${callee.property.name}'`
|
811
|
+
});
|
812
|
+
}
|
813
|
+
}
|
814
|
+
}
|
815
|
+
};
|
816
|
+
}
|
817
|
+
};
|
818
|
+
|
819
|
+
var noUnnecessaryTemplateLiterals = {
|
820
|
+
meta: {
|
821
|
+
type: 'problem',
|
822
|
+
docs: {
|
823
|
+
description: 'Check if a template string contains only one ${}',
|
824
|
+
recommended: true
|
825
|
+
},
|
826
|
+
fixable: 'code',
|
827
|
+
schema: []
|
828
|
+
},
|
829
|
+
create(context) {
|
830
|
+
return {
|
831
|
+
TemplateLiteral(node) {
|
832
|
+
const code = context.sourceCode.getText(node);
|
833
|
+
if (
|
834
|
+
code.startsWith('`${') &&
|
835
|
+
code.endsWith('}`') &&
|
836
|
+
code.split('${').length === 2
|
837
|
+
) {
|
838
|
+
context.report({
|
839
|
+
node,
|
840
|
+
message: 'Unnecessary template string with only one ${}.',
|
841
|
+
fix(fixer) {
|
842
|
+
return fixer.replaceText(
|
843
|
+
node,
|
844
|
+
code.substring(3, code.length - 2)
|
845
|
+
);
|
846
|
+
}
|
847
|
+
});
|
848
|
+
}
|
849
|
+
}
|
850
|
+
};
|
851
|
+
}
|
852
|
+
};
|
853
|
+
|
769
854
|
var betterExhaustiveDeps = {
|
770
855
|
meta: {
|
771
856
|
type: 'suggestion',
|
@@ -2497,41 +2582,6 @@ var preferSxProp = {
|
|
2497
2582
|
}
|
2498
2583
|
};
|
2499
2584
|
|
2500
|
-
var noUnnecessaryTemplateLiterals = {
|
2501
|
-
meta: {
|
2502
|
-
type: 'problem',
|
2503
|
-
docs: {
|
2504
|
-
description: 'Check if a template string contains only one ${}',
|
2505
|
-
recommended: true
|
2506
|
-
},
|
2507
|
-
fixable: 'code',
|
2508
|
-
schema: []
|
2509
|
-
},
|
2510
|
-
create(context) {
|
2511
|
-
return {
|
2512
|
-
TemplateLiteral(node) {
|
2513
|
-
const code = context.sourceCode.getText(node);
|
2514
|
-
if (
|
2515
|
-
code.startsWith('`${') &&
|
2516
|
-
code.endsWith('}`') &&
|
2517
|
-
code.split('${').length === 2
|
2518
|
-
) {
|
2519
|
-
context.report({
|
2520
|
-
node,
|
2521
|
-
message: 'Unnecessary template string with only one ${}.',
|
2522
|
-
fix(fixer) {
|
2523
|
-
return fixer.replaceText(
|
2524
|
-
node,
|
2525
|
-
code.substring(3, code.length - 2)
|
2526
|
-
);
|
2527
|
-
}
|
2528
|
-
});
|
2529
|
-
}
|
2530
|
-
}
|
2531
|
-
};
|
2532
|
-
}
|
2533
|
-
};
|
2534
|
-
|
2535
2585
|
var ruleFiles = /*#__PURE__*/Object.freeze({
|
2536
2586
|
__proto__: null,
|
2537
2587
|
rules_import_enforce_icon_alias: enforceIconAlias,
|
@@ -2544,15 +2594,16 @@ var ruleFiles = /*#__PURE__*/Object.freeze({
|
|
2544
2594
|
rules_react_hook_use_ref: hookUseRef,
|
2545
2595
|
rules_react_prefer_named_property_access: preferNamedPropertyAccess,
|
2546
2596
|
rules_react_prefer_sx_prop: preferSxProp,
|
2547
|
-
rules_stylistic_no_unnecessary_template_literals: noUnnecessaryTemplateLiterals,
|
2548
2597
|
rules_tss_class_naming: classNaming,
|
2549
2598
|
rules_tss_no_color_value: noColorValue,
|
2550
|
-
rules_tss_unused_classes: unusedClasses
|
2599
|
+
rules_tss_unused_classes: unusedClasses,
|
2600
|
+
rules_unprefixed_no_async_array_methods: noAsyncArrayMethods,
|
2601
|
+
rules_unprefixed_no_unnecessary_template_literals: noUnnecessaryTemplateLiterals
|
2551
2602
|
});
|
2552
2603
|
|
2553
2604
|
const rules = {};
|
2554
2605
|
Object.keys(ruleFiles).forEach(key => {
|
2555
|
-
const ruleKey = key.replace(/^rules_/, '');
|
2606
|
+
const ruleKey = key.replace(/^rules_/, '').replace(/^unprefixed_/, '');
|
2556
2607
|
const finalKey = ruleKey.replace(/_/g, '-');
|
2557
2608
|
rules[finalKey] = ruleFiles[key];
|
2558
2609
|
});
|
@@ -2562,6 +2613,8 @@ var index = {
|
|
2562
2613
|
recommended: {
|
2563
2614
|
plugins: ['@agilebot'],
|
2564
2615
|
rules: {
|
2616
|
+
'@agilebot/no-unnecessary-template-literals': 'error',
|
2617
|
+
'@agilebot/no-async-array-methods': 'error',
|
2565
2618
|
'@agilebot/react-prefer-named-property-access': 'error',
|
2566
2619
|
'@agilebot/react-hook-use-ref': 'warn',
|
2567
2620
|
'@agilebot/react-prefer-sx-prop': 'error',
|
@@ -2569,8 +2622,7 @@ var index = {
|
|
2569
2622
|
'@agilebot/tss-no-color-value': 'error',
|
2570
2623
|
'@agilebot/tss-class-naming': 'error',
|
2571
2624
|
'@agilebot/import-enforce-icon-alias': 'error',
|
2572
|
-
'@agilebot/import-monorepo': 'error'
|
2573
|
-
'@agilebot/stylistic-no-unnecessary-template-literals': 'error'
|
2625
|
+
'@agilebot/import-monorepo': 'error'
|
2574
2626
|
},
|
2575
2627
|
settings: {
|
2576
2628
|
react: {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@agilebot/eslint-plugin",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.3",
|
4
4
|
"description": "Agilebot's ESLint plugin",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"dependencies": {
|
21
21
|
"@typescript-eslint/utils": "~7.7.0",
|
22
22
|
"eslint-plugin-react": "^7.34.1",
|
23
|
-
"@agilebot/eslint-utils": "0.3.
|
23
|
+
"@agilebot/eslint-utils": "0.3.3"
|
24
24
|
},
|
25
25
|
"peerDependencies": {
|
26
26
|
"eslint": "^7.0.0 || ^8.0.0"
|