@agilebot/eslint-plugin 0.3.0 → 0.3.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/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.2
|
3
3
|
*
|
4
4
|
* Copyright (c) Agilebot, Inc. and its affiliates.
|
5
5
|
*
|
@@ -766,41 +766,6 @@ var unusedClasses = {
|
|
766
766
|
}
|
767
767
|
};
|
768
768
|
|
769
|
-
var noUnnecessaryTemplateLiterals = {
|
770
|
-
meta: {
|
771
|
-
type: 'problem',
|
772
|
-
docs: {
|
773
|
-
description: 'Check if a template string contains only one ${}',
|
774
|
-
recommended: true
|
775
|
-
},
|
776
|
-
fixable: 'code',
|
777
|
-
schema: []
|
778
|
-
},
|
779
|
-
create(context) {
|
780
|
-
return {
|
781
|
-
TemplateLiteral(node) {
|
782
|
-
const code = context.sourceCode.getText(node);
|
783
|
-
if (
|
784
|
-
code.startsWith('`${') &&
|
785
|
-
code.endsWith('}`') &&
|
786
|
-
code.split('${').length === 2
|
787
|
-
) {
|
788
|
-
context.report({
|
789
|
-
node,
|
790
|
-
message: 'Unnecessary template string with only one ${}.',
|
791
|
-
fix(fixer) {
|
792
|
-
return fixer.replaceText(
|
793
|
-
node,
|
794
|
-
code.substring(3, code.length - 2)
|
795
|
-
);
|
796
|
-
}
|
797
|
-
});
|
798
|
-
}
|
799
|
-
}
|
800
|
-
};
|
801
|
-
}
|
802
|
-
};
|
803
|
-
|
804
769
|
var betterExhaustiveDeps = {
|
805
770
|
meta: {
|
806
771
|
type: 'suggestion',
|
@@ -2532,6 +2497,91 @@ var preferSxProp = {
|
|
2532
2497
|
}
|
2533
2498
|
};
|
2534
2499
|
|
2500
|
+
var noAsyncArrayMethods = {
|
2501
|
+
meta: {
|
2502
|
+
docs: {
|
2503
|
+
description:
|
2504
|
+
'No async callback for Array methods forEach, map, filter, reduce, some, every, etc.',
|
2505
|
+
category: 'Array',
|
2506
|
+
recommended: true
|
2507
|
+
},
|
2508
|
+
fixable: undefined,
|
2509
|
+
schema: []
|
2510
|
+
},
|
2511
|
+
create: function (context) {
|
2512
|
+
return {
|
2513
|
+
ExpressionStatement: function (node) {
|
2514
|
+
const notAllowedArrayMethods = [
|
2515
|
+
'forEach',
|
2516
|
+
'filter',
|
2517
|
+
'some',
|
2518
|
+
'every',
|
2519
|
+
'map',
|
2520
|
+
'reduce',
|
2521
|
+
'reduceRight',
|
2522
|
+
'flatMap',
|
2523
|
+
'find',
|
2524
|
+
'findIndex',
|
2525
|
+
'findLast',
|
2526
|
+
'findLastIndex'
|
2527
|
+
];
|
2528
|
+
const { callee } = node.expression;
|
2529
|
+
if (!callee || !callee.property || !callee.property.name) {
|
2530
|
+
return;
|
2531
|
+
}
|
2532
|
+
if (notAllowedArrayMethods.includes(callee.property.name)) {
|
2533
|
+
const functionArguments = node.expression.arguments.find(n => {
|
2534
|
+
return ['ArrowFunctionExpression', 'FunctionExpression'].includes(
|
2535
|
+
n.type
|
2536
|
+
);
|
2537
|
+
});
|
2538
|
+
if (functionArguments && functionArguments.async) {
|
2539
|
+
context.report({
|
2540
|
+
node,
|
2541
|
+
message: `No async function in method '${callee.property.name}'`
|
2542
|
+
});
|
2543
|
+
}
|
2544
|
+
}
|
2545
|
+
}
|
2546
|
+
};
|
2547
|
+
}
|
2548
|
+
};
|
2549
|
+
|
2550
|
+
var noUnnecessaryTemplateLiterals = {
|
2551
|
+
meta: {
|
2552
|
+
type: 'problem',
|
2553
|
+
docs: {
|
2554
|
+
description: 'Check if a template string contains only one ${}',
|
2555
|
+
recommended: true
|
2556
|
+
},
|
2557
|
+
fixable: 'code',
|
2558
|
+
schema: []
|
2559
|
+
},
|
2560
|
+
create(context) {
|
2561
|
+
return {
|
2562
|
+
TemplateLiteral(node) {
|
2563
|
+
const code = context.sourceCode.getText(node);
|
2564
|
+
if (
|
2565
|
+
code.startsWith('`${') &&
|
2566
|
+
code.endsWith('}`') &&
|
2567
|
+
code.split('${').length === 2
|
2568
|
+
) {
|
2569
|
+
context.report({
|
2570
|
+
node,
|
2571
|
+
message: 'Unnecessary template string with only one ${}.',
|
2572
|
+
fix(fixer) {
|
2573
|
+
return fixer.replaceText(
|
2574
|
+
node,
|
2575
|
+
code.substring(3, code.length - 2)
|
2576
|
+
);
|
2577
|
+
}
|
2578
|
+
});
|
2579
|
+
}
|
2580
|
+
}
|
2581
|
+
};
|
2582
|
+
}
|
2583
|
+
};
|
2584
|
+
|
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.2",
|
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.2"
|
24
24
|
},
|
25
25
|
"peerDependencies": {
|
26
26
|
"eslint": "^7.0.0 || ^8.0.0"
|