@blumintinc/eslint-plugin-blumint 1.1.1 → 1.1.3
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
|
@@ -56,24 +56,37 @@ Or use the recommended config:
|
|
|
56
56
|
✅ Set in the `recommended` configuration.\
|
|
57
57
|
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).
|
|
58
58
|
|
|
59
|
-
| Name
|
|
60
|
-
|
|
|
61
|
-
| [array-methods-this-context](docs/rules/array-methods-this-context.md)
|
|
62
|
-
| [class-methods-read-top-to-bottom](docs/rules/class-methods-read-top-to-bottom.md)
|
|
63
|
-
| [
|
|
64
|
-
| [
|
|
65
|
-
| [
|
|
66
|
-
| [
|
|
67
|
-
| [
|
|
68
|
-
| [
|
|
69
|
-
| [
|
|
70
|
-
| [
|
|
71
|
-
| [
|
|
72
|
-
| [
|
|
73
|
-
| [
|
|
74
|
-
| [no-
|
|
75
|
-
| [
|
|
76
|
-
| [
|
|
77
|
-
| [
|
|
59
|
+
| Name | Description | 💼 | ⚠️ | 🔧 |
|
|
60
|
+
| :--------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------- | :- | :- | :- |
|
|
61
|
+
| [array-methods-this-context](docs/rules/array-methods-this-context.md) | Prevent misuse of Array methods in OOP | | ✅ | |
|
|
62
|
+
| [class-methods-read-top-to-bottom](docs/rules/class-methods-read-top-to-bottom.md) | Ensures classes read linearly from top to bottom. | | ✅ | 🔧 |
|
|
63
|
+
| [consistent-callback-naming](docs/rules/consistent-callback-naming.md) | Enforce consistent naming conventions for callback props and functions | ✅ | | 🔧 |
|
|
64
|
+
| [dynamic-https-errors](docs/rules/dynamic-https-errors.md) | Dynamic error details should only be in the third argument of the HttpsError constructor. The second argument is hashed to produce a unique id. | | ✅ | |
|
|
65
|
+
| [enforce-callable-types](docs/rules/enforce-callable-types.md) | Enforce Params and Response type exports in callable functions | ✅ | | |
|
|
66
|
+
| [enforce-callback-memo](docs/rules/enforce-callback-memo.md) | Enforce useCallback or useMemo for inline functions in JSX props | ✅ | | |
|
|
67
|
+
| [enforce-dynamic-firebase-imports](docs/rules/enforce-dynamic-firebase-imports.md) | Enforce dynamic importing for modules within the firebaseCloud directory | ✅ | | |
|
|
68
|
+
| [enforce-identifiable-firestore-type](docs/rules/enforce-identifiable-firestore-type.md) | Enforce that Firestore type definitions extend Identifiable and match their folder name | ✅ | | |
|
|
69
|
+
| [enforce-safe-stringify](docs/rules/enforce-safe-stringify.md) | Enforce using safe-stable-stringify instead of JSON.stringify | ✅ | | 🔧 |
|
|
70
|
+
| [export-if-in-doubt](docs/rules/export-if-in-doubt.md) | All top-level const definitions, type definitions, and functions should be exported | | | |
|
|
71
|
+
| [extract-global-constants](docs/rules/extract-global-constants.md) | Extract static constants and functions to the global scope when possible | | ✅ | |
|
|
72
|
+
| [generic-starts-with-t](docs/rules/generic-starts-with-t.md) | Enforce TypeScript generic types to start with T | | ✅ | |
|
|
73
|
+
| [global-const-style](docs/rules/global-const-style.md) | Enforce UPPER_SNAKE_CASE and as const for global static constants | ✅ | | 🔧 |
|
|
74
|
+
| [no-async-array-filter](docs/rules/no-async-array-filter.md) | Disallow async callbacks for Array.filter | ✅ | | |
|
|
75
|
+
| [no-async-foreach](docs/rules/no-async-foreach.md) | Disallow Array.forEach with an async callback function | ✅ | | |
|
|
76
|
+
| [no-conditional-literals-in-jsx](docs/rules/no-conditional-literals-in-jsx.md) | Disallow use of conditional literals in JSX code | ✅ | | |
|
|
77
|
+
| [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) | ✅ | | |
|
|
78
|
+
| [no-jsx-whitespace-literal](docs/rules/no-jsx-whitespace-literal.md) | Disallow the use of {" "} elements in JSX code | ✅ | | |
|
|
79
|
+
| [no-misused-switch-case](docs/rules/no-misused-switch-case.md) | Prevent misuse of logical OR in switch case statements | ✅ | | |
|
|
80
|
+
| [no-unpinned-dependencies](docs/rules/no-unpinned-dependencies.md) | Enforces pinned dependencies | ✅ | | 🔧 |
|
|
81
|
+
| [no-unused-props](docs/rules/no-unused-props.md) | Detect unused props in React component type definitions | ✅ | | 🔧 |
|
|
82
|
+
| [no-useless-fragment](docs/rules/no-useless-fragment.md) | Prevent unnecessary use of React fragments | | ✅ | 🔧 |
|
|
83
|
+
| [prefer-fragment-shorthand](docs/rules/prefer-fragment-shorthand.md) | Prefer <> shorthand for <React.Fragment> | | ✅ | 🔧 |
|
|
84
|
+
| [prefer-type-over-interface](docs/rules/prefer-type-over-interface.md) | Prefer using type alias over interface | | ✅ | 🔧 |
|
|
85
|
+
| [require-dynamic-firebase-imports](docs/rules/require-dynamic-firebase-imports.md) | Enforce dynamic imports for Firebase dependencies | ✅ | | 🔧 |
|
|
86
|
+
| [require-https-error](docs/rules/require-https-error.md) | Enforce using proprietary HttpsError instead of throw new Error or firebase-admin HttpsError in functions/src | ✅ | | |
|
|
87
|
+
| [require-image-overlayed](docs/rules/require-image-overlayed.md) | Enforce using ImageOverlayed component instead of next/image or img tags | ✅ | | 🔧 |
|
|
88
|
+
| [require-memo](docs/rules/require-memo.md) | React components must be memoized | ✅ | | 🔧 |
|
|
89
|
+
| [require-usememo-object-literals](docs/rules/require-usememo-object-literals.md) | Enforce using useMemo for inline object literals passed as props to JSX components | ✅ | | |
|
|
90
|
+
| [use-custom-router](docs/rules/use-custom-router.md) | Enforce using src/hooks/routing/useRouter instead of next/router | ✅ | | 🔧 |
|
|
78
91
|
|
|
79
92
|
<!-- end auto-generated rules list -->
|
package/lib/index.js
CHANGED
|
@@ -32,10 +32,11 @@ const require_https_error_1 = __importDefault(require("./rules/require-https-err
|
|
|
32
32
|
const use_custom_router_1 = require("./rules/use-custom-router");
|
|
33
33
|
const require_image_overlayed_1 = __importDefault(require("./rules/require-image-overlayed"));
|
|
34
34
|
const require_usememo_object_literals_1 = require("./rules/require-usememo-object-literals");
|
|
35
|
+
const enforce_safe_stringify_1 = require("./rules/enforce-safe-stringify");
|
|
35
36
|
module.exports = {
|
|
36
37
|
meta: {
|
|
37
38
|
name: '@blumintinc/eslint-plugin-blumint',
|
|
38
|
-
version: '1.1.
|
|
39
|
+
version: '1.1.3',
|
|
39
40
|
},
|
|
40
41
|
parseOptions: {
|
|
41
42
|
ecmaVersion: 2020,
|
|
@@ -73,6 +74,7 @@ module.exports = {
|
|
|
73
74
|
'@blumintinc/blumint/use-custom-router': 'error',
|
|
74
75
|
'@blumintinc/blumint/require-image-overlayed': 'error',
|
|
75
76
|
'@blumintinc/blumint/require-usememo-object-literals': 'error',
|
|
77
|
+
'@blumintinc/blumint/enforce-safe-stringify': 'error',
|
|
76
78
|
},
|
|
77
79
|
},
|
|
78
80
|
},
|
|
@@ -106,6 +108,7 @@ module.exports = {
|
|
|
106
108
|
'use-custom-router': use_custom_router_1.useCustomRouter,
|
|
107
109
|
'require-image-overlayed': require_image_overlayed_1.default,
|
|
108
110
|
'require-usememo-object-literals': require_usememo_object_literals_1.requireUseMemoObjectLiterals,
|
|
111
|
+
'enforce-safe-stringify': enforce_safe_stringify_1.enforceStableStringify,
|
|
109
112
|
},
|
|
110
113
|
};
|
|
111
114
|
//# sourceMappingURL=index.js.map
|
|
@@ -22,8 +22,10 @@ exports.enforceCallableTypes = (0, createRule_1.createRule)({
|
|
|
22
22
|
defaultOptions: [],
|
|
23
23
|
create(context) {
|
|
24
24
|
const filename = context.getFilename();
|
|
25
|
-
// Only apply to .f.ts files in the callable directory
|
|
26
|
-
if (!filename.endsWith('.f.ts') ||
|
|
25
|
+
// Only apply to .f.ts files in the callable directory, but ignore scripts directory
|
|
26
|
+
if (!filename.endsWith('.f.ts') ||
|
|
27
|
+
!filename.includes('/callable/') ||
|
|
28
|
+
filename.includes('/callable/scripts/')) {
|
|
27
29
|
return {};
|
|
28
30
|
}
|
|
29
31
|
let hasParamsExport = false;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enforceStableStringify = void 0;
|
|
4
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
+
const createRule_1 = require("../utils/createRule");
|
|
6
|
+
exports.enforceStableStringify = (0, createRule_1.createRule)({
|
|
7
|
+
name: 'enforce-safe-stringify',
|
|
8
|
+
meta: {
|
|
9
|
+
type: 'problem',
|
|
10
|
+
docs: {
|
|
11
|
+
description: 'Enforce using safe-stable-stringify instead of JSON.stringify',
|
|
12
|
+
recommended: 'error',
|
|
13
|
+
},
|
|
14
|
+
fixable: 'code',
|
|
15
|
+
schema: [],
|
|
16
|
+
messages: {
|
|
17
|
+
useStableStringify: 'Use safe-stable-stringify instead of JSON.stringify for safer serialization',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultOptions: [],
|
|
21
|
+
create(context) {
|
|
22
|
+
let hasStringifyImport = false;
|
|
23
|
+
return {
|
|
24
|
+
ImportDeclaration(node) {
|
|
25
|
+
if (node.source.value === 'safe-stable-stringify' &&
|
|
26
|
+
node.specifiers.some((specifier) => specifier.type === utils_1.AST_NODE_TYPES.ImportDefaultSpecifier &&
|
|
27
|
+
specifier.local.name === 'stringify')) {
|
|
28
|
+
hasStringifyImport = true;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
MemberExpression(node) {
|
|
32
|
+
if (node.object.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
33
|
+
node.object.name === 'JSON' &&
|
|
34
|
+
node.property.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
35
|
+
node.property.name === 'stringify') {
|
|
36
|
+
context.report({
|
|
37
|
+
node,
|
|
38
|
+
messageId: 'useStableStringify',
|
|
39
|
+
fix(fixer) {
|
|
40
|
+
const fixes = [];
|
|
41
|
+
// Add import if not present
|
|
42
|
+
if (!hasStringifyImport) {
|
|
43
|
+
const program = context.getSourceCode().ast;
|
|
44
|
+
const firstImport = program.body.find((node) => node.type === utils_1.AST_NODE_TYPES.ImportDeclaration);
|
|
45
|
+
const importStatement = "import stringify from 'safe-stable-stringify';\n";
|
|
46
|
+
if (firstImport) {
|
|
47
|
+
fixes.push(fixer.insertTextBefore(firstImport, importStatement));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
fixes.push(fixer.insertTextBefore(program.body[0], importStatement));
|
|
51
|
+
}
|
|
52
|
+
hasStringifyImport = true;
|
|
53
|
+
}
|
|
54
|
+
// Replace JSON.stringify with stringify
|
|
55
|
+
fixes.push(fixer.replaceText(node, 'stringify'));
|
|
56
|
+
return fixes;
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=enforce-safe-stringify.js.map
|