@blumintinc/eslint-plugin-blumint 0.1.12 → 0.1.13
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 +5 -5
- package/docs/rules/export-if-in-doubt.md +0 -2
- package/docs/rules/extract-global-constants.md +0 -2
- package/docs/rules/no-conditional-literals-in-jsx.md +0 -2
- package/docs/rules/no-useless-fragment.md +2 -0
- package/docs/rules/prefer-type-over-interface.md +2 -0
- package/lib/index.js +3 -3
- package/lib/rules/no-useless-fragment.js +16 -0
- package/lib/rules/prefer-type-over-interface.js +15 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,18 +59,18 @@ Or use the recommended config:
|
|
|
59
59
|
| Name | Description | 💼 | ⚠️ | 🔧 |
|
|
60
60
|
| :----------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------- | :- | :- | :- |
|
|
61
61
|
| [array-methods-this-context](docs/rules/array-methods-this-context.md) | Prevent misuse of Array methods in OOP | | ✅ | |
|
|
62
|
-
| [export-if-in-doubt](docs/rules/export-if-in-doubt.md) | All top-level const definitions, type definitions, and functions should be exported | |
|
|
63
|
-
| [extract-global-constants](docs/rules/extract-global-constants.md) | Extract constants/functions to the global scope when possible | |
|
|
62
|
+
| [export-if-in-doubt](docs/rules/export-if-in-doubt.md) | All top-level const definitions, type definitions, and functions should be exported | | | |
|
|
63
|
+
| [extract-global-constants](docs/rules/extract-global-constants.md) | Extract constants/functions to the global scope when possible | | | |
|
|
64
64
|
| [generic-starts-with-t](docs/rules/generic-starts-with-t.md) | Enforce TypeScript generic types to start with T | | ✅ | |
|
|
65
65
|
| [no-async-array-filter](docs/rules/no-async-array-filter.md) | Disallow async callbacks for Array.filter | ✅ | | |
|
|
66
66
|
| [no-async-foreach](docs/rules/no-async-foreach.md) | Disallow Array.forEach with an async callback function | ✅ | | |
|
|
67
|
-
| [no-conditional-literals-in-jsx](docs/rules/no-conditional-literals-in-jsx.md) | Disallow use of conditional literals in JSX code |
|
|
67
|
+
| [no-conditional-literals-in-jsx](docs/rules/no-conditional-literals-in-jsx.md) | Disallow use of conditional literals in JSX code | | | |
|
|
68
68
|
| [no-filter-without-return](docs/rules/no-filter-without-return.md) | Disallow Array.filter callbacks without an explicit return (if part of a block statement) | ✅ | | |
|
|
69
69
|
| [no-misused-switch-case](docs/rules/no-misused-switch-case.md) | Prevent misuse of logical OR in switch case statements | ✅ | | |
|
|
70
70
|
| [no-unpinned-dependencies](docs/rules/no-unpinned-dependencies.md) | Enforces pinned dependencies | ✅ | | 🔧 |
|
|
71
|
-
| [no-useless-fragment](docs/rules/no-useless-fragment.md) | Prevent unnecessary use of React fragments | | ✅ |
|
|
71
|
+
| [no-useless-fragment](docs/rules/no-useless-fragment.md) | Prevent unnecessary use of React fragments | | ✅ | 🔧 |
|
|
72
72
|
| [prefer-fragment-shorthand](docs/rules/prefer-fragment-shorthand.md) | Prefer <> shorthand for <React.Fragment> | | ✅ | 🔧 |
|
|
73
|
-
| [prefer-type-over-interface](docs/rules/prefer-type-over-interface.md) | Prefer using type alias over interface | | ✅ |
|
|
73
|
+
| [prefer-type-over-interface](docs/rules/prefer-type-over-interface.md) | Prefer using type alias over interface | | ✅ | 🔧 |
|
|
74
74
|
|
|
75
75
|
<!-- end auto-generated rules list -->
|
|
76
76
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# All top-level const definitions, type definitions, and functions should be exported (`@blumintinc/blumint/export-if-in-doubt`)
|
|
2
2
|
|
|
3
|
-
⚠️ This rule _warns_ in the ✅ `recommended` config.
|
|
4
|
-
|
|
5
3
|
<!-- end auto-generated rule header -->
|
|
6
4
|
|
|
7
5
|
This rule enforces that all top-level const definitions, type definitions, and functions should always be exported. If not done, this rule will trigger a warning message suggesting to export the declaration.
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# Extract constants/functions to the global scope when possible (`@blumintinc/blumint/extract-global-constants`)
|
|
2
2
|
|
|
3
|
-
⚠️ This rule _warns_ in the ✅ `recommended` config.
|
|
4
|
-
|
|
5
3
|
<!-- end auto-generated rule header -->
|
|
6
4
|
|
|
7
5
|
This rule suggests that if a constant or a function within a function or block scope doesn't depend on any other identifiers in that scope, it should be moved to the global scope. This aims to improve the readability of the code and the possibility of reuse.
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# Disallow use of conditional literals in JSX code (`@blumintinc/blumint/no-conditional-literals-in-jsx`)
|
|
2
2
|
|
|
3
|
-
💼 This rule is enabled in the ✅ `recommended` config.
|
|
4
|
-
|
|
5
3
|
<!-- end auto-generated rule header -->
|
|
6
4
|
|
|
7
5
|
This rule disallows the use of conditional literals in JSX.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
⚠️ This rule _warns_ in the ✅ `recommended` config.
|
|
4
4
|
|
|
5
|
+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
|
6
|
+
|
|
5
7
|
<!-- end auto-generated rule header -->
|
|
6
8
|
|
|
7
9
|
This rule enforces that React fragments (`<>...</>`) are only used when necessary. A fragment is deemed unnecessary if it wraps only a single child.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
⚠️ This rule _warns_ in the ✅ `recommended` config.
|
|
4
4
|
|
|
5
|
+
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
|
6
|
+
|
|
5
7
|
<!-- end auto-generated rule header -->
|
|
6
8
|
|
|
7
9
|
This rule prefers the use of `Type` over `Interface` in Typescript.
|
package/lib/index.js
CHANGED
|
@@ -16,7 +16,7 @@ const prefer_type_over_interface_1 = require("./rules/prefer-type-over-interface
|
|
|
16
16
|
module.exports = {
|
|
17
17
|
meta: {
|
|
18
18
|
name: '@blumintinc/eslint-plugin-blumint',
|
|
19
|
-
version: '0.1.
|
|
19
|
+
version: '0.1.13',
|
|
20
20
|
},
|
|
21
21
|
parseOptions: {
|
|
22
22
|
ecmaVersion: 2020,
|
|
@@ -26,8 +26,8 @@ module.exports = {
|
|
|
26
26
|
plugins: ['@blumintinc/blumint'],
|
|
27
27
|
rules: {
|
|
28
28
|
'@blumintinc/blumint/array-methods-this-context': 'warn',
|
|
29
|
-
'@blumintinc/blumint/export-if-in-doubt': 'warn',
|
|
30
|
-
'@blumintinc/blumint/extract-global-constants': 'warn',
|
|
29
|
+
// '@blumintinc/blumint/export-if-in-doubt': 'warn',
|
|
30
|
+
// '@blumintinc/blumint/extract-global-constants': 'warn',
|
|
31
31
|
'@blumintinc/blumint/generic-starts-with-t': 'warn',
|
|
32
32
|
'@blumintinc/blumint/no-async-array-filter': 'error',
|
|
33
33
|
'@blumintinc/blumint/no-async-foreach': 'error',
|
|
@@ -9,6 +9,21 @@ exports.noUselessFragment = {
|
|
|
9
9
|
context.report({
|
|
10
10
|
node,
|
|
11
11
|
messageId: 'noUselessFragment',
|
|
12
|
+
fix(fixer) {
|
|
13
|
+
const sourceCode = context.getSourceCode();
|
|
14
|
+
const openingFragment = sourceCode.getFirstToken(node);
|
|
15
|
+
const closingFragment = sourceCode.getLastToken(node);
|
|
16
|
+
return [
|
|
17
|
+
fixer.removeRange([
|
|
18
|
+
openingFragment.range[0],
|
|
19
|
+
openingFragment.range[0] + 2,
|
|
20
|
+
]),
|
|
21
|
+
fixer.removeRange([
|
|
22
|
+
closingFragment.range[0] - 3,
|
|
23
|
+
closingFragment.range[0],
|
|
24
|
+
]),
|
|
25
|
+
];
|
|
26
|
+
},
|
|
12
27
|
});
|
|
13
28
|
}
|
|
14
29
|
},
|
|
@@ -24,6 +39,7 @@ exports.noUselessFragment = {
|
|
|
24
39
|
noUselessFragment: 'React fragment is unnecessary when wrapping a single child',
|
|
25
40
|
},
|
|
26
41
|
schema: [],
|
|
42
|
+
fixable: 'code',
|
|
27
43
|
},
|
|
28
44
|
defaultOptions: [],
|
|
29
45
|
};
|
|
@@ -14,6 +14,7 @@ exports.preferTypeOverInterface = (0, createRule_1.createRule)({
|
|
|
14
14
|
messages: {
|
|
15
15
|
preferType: 'Prefer using type alias over interface.',
|
|
16
16
|
},
|
|
17
|
+
fixable: 'code',
|
|
17
18
|
},
|
|
18
19
|
defaultOptions: [],
|
|
19
20
|
create(context) {
|
|
@@ -22,6 +23,20 @@ exports.preferTypeOverInterface = (0, createRule_1.createRule)({
|
|
|
22
23
|
context.report({
|
|
23
24
|
node,
|
|
24
25
|
messageId: 'preferType',
|
|
26
|
+
fix(fixer) {
|
|
27
|
+
const sourceCode = context.getSourceCode();
|
|
28
|
+
const openingBrace = sourceCode.getTokenAfter(node.id, {
|
|
29
|
+
filter: (token) => token.value === '{',
|
|
30
|
+
});
|
|
31
|
+
const fixes = [
|
|
32
|
+
fixer.replaceTextRange([node.range[0], node.id.range[1]], `type ${node.id.name} =`),
|
|
33
|
+
];
|
|
34
|
+
if (node.extends && node.extends.length > 0 && openingBrace) {
|
|
35
|
+
const extendsKeyword = sourceCode.getFirstTokenBetween(node.id, openingBrace, { filter: (token) => token.value === 'extends' });
|
|
36
|
+
fixes.push(fixer.remove(extendsKeyword), fixer.insertTextBefore(openingBrace, '& '));
|
|
37
|
+
}
|
|
38
|
+
return fixes;
|
|
39
|
+
},
|
|
25
40
|
});
|
|
26
41
|
},
|
|
27
42
|
};
|