@bigbinary/eslint-plugin-neeto 1.3.0 → 1.5.0
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 +53 -17
- package/dist/index.js +44 -5
- package/dist/resolveConfigWorker.js +8 -0
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -46,12 +46,15 @@ module.exports = {
|
|
|
46
46
|
|
|
47
47
|
## Exported rules
|
|
48
48
|
|
|
49
|
+
ESLint rules are categorized as either errors or warnings based on the severity
|
|
50
|
+
of the issues identified in JavaScript code.
|
|
51
|
+
|
|
52
|
+
### Errors
|
|
53
|
+
|
|
49
54
|
- [no-unnecessary-classnames](./docs/src/rules/no-unnecessary-classnames.md)
|
|
50
|
-
- [no-snake-case-destructuring-for-use-query-params-and-get-query-params](./docs/src/rules/no-snake-case-destructuring-for-use-query-params-and-get-query-params.md)
|
|
51
55
|
- [no-local-storage](./docs/src/rules/no-local-storage.md)
|
|
52
56
|
- [no-lowercase-on-translation](./docs/src/rules/no-lowercase-on-translation.md)
|
|
53
57
|
- [use-use-query-client-hook](./docs/src/rules/use-use-query-client-hook.md)
|
|
54
|
-
- [use-early-return](./docs/src/rules/use-early-return.md)
|
|
55
58
|
- [use-classnames-for-dynamic-classes](./docs/src/rules/use-classnames-for-dynamic-classes.md)
|
|
56
59
|
- [use-use-mutation-with-invalidation-hook](./docs/src/rules/use-use-mutation-with-invalidation-hook.md)
|
|
57
60
|
- [no-withT-for-smart-components](./docs/src/rules/no-withT-for-smart-components.md)
|
|
@@ -61,22 +64,16 @@ module.exports = {
|
|
|
61
64
|
- [no-unnecessary-if-condition](./docs/src/rules/no-unnecessary-if-condition.md)
|
|
62
65
|
- [api-connector-name-should-match-filename](./docs/src/rules/api-connector-name-should-match-filename.md)
|
|
63
66
|
- [api-connector-should-use-default-export](./docs/src/rules/api-connector-should-use-default-export.md)
|
|
64
|
-
- [combine-multiple-independent-awaits](./docs/src/rules/combine-multiple-independent-awaits.md)
|
|
65
|
-
- [consistent-button-link-anchor](./docs/src/rules/consistent-button-link-anchor.md)
|
|
66
67
|
- [ensure-compact-objects](./docs/src/rules/ensure-compact-objects.md)
|
|
67
68
|
- [ensure-formik-eager-validation](./docs/src/rules/ensure-formik-eager-validation.md)
|
|
68
69
|
- [ensure-zustand-stores-are-type-annotated](./docs/src/rules/ensure-zustand-stores-are-type-annotated.md)
|
|
69
70
|
- [files-inside-react-query-folder-should-end-with-api](./docs/src/rules/files-inside-react-query-folder-should-end-with-api.md)
|
|
70
|
-
- [file-name-and-export-name-standards](./docs/src/rules/file-name-and-export-name-standards.md)
|
|
71
|
-
- [hard-coded-strings-should-be-localized](./docs/src/rules/hard-coded-strings-should-be-localized.md)
|
|
72
71
|
- [minimize-zustand-store-access-scope](./docs/src/rules/minimize-zustand-store-access-scope.md)
|
|
73
|
-
- [neetocommons-tips](./docs/src/rules/neetocommons-tips.md)
|
|
74
72
|
- [no-axios-import-outside-apis](./docs/src/rules/no-axios-import-outside-apis.md)
|
|
75
73
|
- [no-blacklisted-imports](./docs/src/rules/no-blacklisted-imports.md)
|
|
76
74
|
- [no-conditional-overlays](./docs/src/rules/no-conditional-overlays.md)
|
|
77
75
|
- [no-deprecated-imports-from-zustand](./docs/src/rules/no-deprecated-imports-from-zustand.md)
|
|
78
76
|
- [no-dangling-constants](./docs/src/rules/no-dangling-constants.md)
|
|
79
|
-
- [no-excess-function-arguments](./docs/src/rules/no-excess-function-arguments.md)
|
|
80
77
|
- [no-globalProps-destructure](./docs/src/rules/no-globalProps-destructure.md)
|
|
81
78
|
- [no-globalProps-reassignment](./docs/src/rules/no-globalProps-reassignment.md)
|
|
82
79
|
- [no-missing-localization](./docs/src/rules/no-missing-localization.md)
|
|
@@ -88,27 +85,21 @@ module.exports = {
|
|
|
88
85
|
- [no-routes-destructure-and-reassignment](./docs/src/rules/no-routes-destructure-and-reassignment.md)
|
|
89
86
|
- [no-translation-functions-in-string-interpolation](./docs/src/rules/no-translation-functions-in-string-interpolation.md)
|
|
90
87
|
- [prefix-neeto-ui-import-alias](./docs/src/rules/prefix-neeto-ui-import-alias.md)
|
|
91
|
-
- [ramda-tips](./docs/src/rules/ramda-tips.md)
|
|
92
88
|
- [routes-should-be-declared-and-default-exported](./docs/src/rules/routes-should-be-declared-and-default-exported.md)
|
|
93
89
|
- [routes-should-match-object-path](./docs/src/rules/routes-should-match-object-path.md)
|
|
94
90
|
- [use-array-methods](./docs/src/rules/use-array-methods.md)
|
|
95
91
|
- [use-axios-config-for-passing-query-parameters](./docs/src/rules/use-axios-config-for-passing-query-parameters.md)
|
|
96
92
|
- [use-camel-case-or-pascal-case-for-function-names](./docs/src/rules/use-camel-case-or-pascal-case-for-function-names.md)
|
|
97
|
-
- [use-common-constants](./docs/src/rules/use-common-constants.md)
|
|
98
93
|
- [use-common-routes](./docs/src/rules/use-common-routes.md)
|
|
99
94
|
- [use-components-children-prop-in-trans](./docs/src/rules/use-components-children-prop-in-trans.md)
|
|
100
95
|
- [use-create-subscription-util-function](./docs/src/rules/use-create-subscription-util-function.md)
|
|
101
96
|
- [use-i18next-plurals](./docs/src/rules/use-i18next-plurals.md)
|
|
102
97
|
- [use-inline-svg-for-render](./docs/src/rules/use-inline-svg-for-render.md)
|
|
103
|
-
- [use-neeto-in-strings](./docs/src/rules/use-neeto-in-strings.md)
|
|
104
|
-
- [use-neetoui-classes](./docs/src/rules/use-neetoui-classes.md)
|
|
105
|
-
- [use-permissions-prop-in-private-route](./docs/src/rules/use-permissions-prop-in-private-route.md)
|
|
106
98
|
- [use-pluralize-package](./docs/src/rules/use-pluralize-package.md)
|
|
107
99
|
- [use-react-query-for-managing-remote-data](./docs/src/rules/use-react-query-for-managing-remote-data.md)
|
|
108
100
|
- [use-snake-case-for-api-connector-filename](./docs/src/rules/use-snake-case-for-api-connector-filename.md)
|
|
109
101
|
- [use-translation-hook-in-components](./docs/src/rules/use-translation-hook-in-components.md)
|
|
110
102
|
- [use-trans-components-and-values-props](./docs/src/rules/use-trans-components-and-values-props.md)
|
|
111
|
-
- [use-webpack-alias](./docs/src/rules/use-webpack-alias.md)
|
|
112
103
|
- [use-zustand-for-global-state-management](./docs/src/rules/use-zustand-for-global-state-management.md)
|
|
113
104
|
- [webpack-aliases-and-jsconfig-paths-should-be-in-sync](./docs/src/rules/webpack-aliases-and-jsconfig-paths-should-be-in-sync.md)
|
|
114
105
|
- [zustand-recommend-comparator-function-usage](./docs/src/rules/zustand-recommend-comparator-function-usage.md)
|
|
@@ -118,13 +109,58 @@ module.exports = {
|
|
|
118
109
|
- [merge-spread-attributes](./docs/src/rules/merge-spread-attributes.md)
|
|
119
110
|
- [props-with-different-key-value-should-be-outside-spread-attribute](./docs/src/rules/props-with-different-key-value-should-be-outside-spread-attribute.md)
|
|
120
111
|
- [no-repetition-in-prop-key-value-names](./docs/src/rules/no-repetition-in-prop-key-value-names.md)
|
|
121
|
-
- [use-functions-and-hooks-from-neeto-commons-frontend.md](./docs/src/rules/use-functions-and-hooks-from-neeto-commons-frontend.md)
|
|
122
112
|
- [zustand-use-with-immutable-actions-wrapper-inside-create](./docs/src/rules/zustand-use-with-immutable-actions-wrapper-inside-create.md)
|
|
123
113
|
- [add-required-peer-dependencies](./docs/src/rules/add-required-peer-dependencies.md)
|
|
124
114
|
- [move-spread-attributes-to-top-position](./docs/src/rules/move-spread-attributes-to-top-position.md)
|
|
125
|
-
- [
|
|
115
|
+
- [use-show-thumbs-up-toastr](./docs/src/rules/use-show-thumbs-up-toastr)
|
|
116
|
+
- [ensure-usestate-has-initial-value](./docs/src/rules/ensure-usestate-has-initial-value.md)
|
|
117
|
+
|
|
118
|
+
### Warnings
|
|
119
|
+
|
|
120
|
+
- [ramda-tips](./docs/src/rules/ramda-tips.md)
|
|
121
|
+
- [combine-multiple-independent-awaits](./docs/src/rules/combine-multiple-independent-awaits.md)
|
|
122
|
+
- [consistent-button-link-anchor](./docs/src/rules/consistent-button-link-anchor.md)
|
|
123
|
+
- [file-name-and-export-name-standards](./docs/src/rules/file-name-and-export-name-standards.md)
|
|
124
|
+
- [hard-coded-strings-should-be-localized](./docs/src/rules/hard-coded-strings-should-be-localized.md)
|
|
126
125
|
- [jsx-prefer-guard-clause.md](./docs/src/rules/jsx-prefer-guard-clause.md)
|
|
127
|
-
- [
|
|
126
|
+
- [neetocommons-tips](./docs/src/rules/neetocommons-tips.md)
|
|
127
|
+
- [no-excess-function-arguments](./docs/src/rules/no-excess-function-arguments.md)
|
|
128
|
+
- [no-snake-case-destructuring-for-use-query-params-and-get-query-params](./docs/src/rules/no-snake-case-destructuring-for-use-query-params-and-get-query-params.md)
|
|
129
|
+
- [prefer-function-reference.md](./docs/src/rules/prefer-function-reference.md)
|
|
130
|
+
- [use-common-constants](./docs/src/rules/use-common-constants.md)
|
|
131
|
+
- [use-early-return](./docs/src/rules/use-early-return.md)
|
|
132
|
+
- [use-functions-and-hooks-from-neeto-commons-frontend.md](./docs/src/rules/use-functions-and-hooks-from-neeto-commons-frontend.md)
|
|
133
|
+
- [use-neeto-in-strings](./docs/src/rules/use-neeto-in-strings.md)
|
|
134
|
+
- [use-neetoui-classes](./docs/src/rules/use-neetoui-classes.md)
|
|
135
|
+
- [use-permissions-prop-in-private-route](./docs/src/rules/use-permissions-prop-in-private-route.md)
|
|
136
|
+
- [use-webpack-alias](./docs/src/rules/use-webpack-alias.md)
|
|
137
|
+
|
|
138
|
+
## Overriding rules
|
|
139
|
+
|
|
140
|
+
### ESLint Errors
|
|
141
|
+
|
|
142
|
+
ESLint errors flag the mandatory coding standards that developers must strictly
|
|
143
|
+
adhere to. These errors are detected by the `pre-commit` hook and in CI checks.
|
|
144
|
+
There may be instances where we intentionally choose to adopt a particular
|
|
145
|
+
coding style and wish to prevent ESLint from throwing errors. In such cases, you
|
|
146
|
+
can temporarily disable the rule responsible for the false alarm by adding a
|
|
147
|
+
comment above the code, specifying the reason why you have disabled that
|
|
148
|
+
particular rule for that line to avoid any future confusion:
|
|
149
|
+
|
|
150
|
+
```js
|
|
151
|
+
// Reason for disabling the rule.
|
|
152
|
+
// eslint-disable-next-line <rule>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### ESLint Warnings
|
|
156
|
+
|
|
157
|
+
When creating an ESLint rule, it may not always be possible to cover every edge
|
|
158
|
+
case and eliminate all false positives. Such rules have been configured as
|
|
159
|
+
warnings instead of errors. These warnings are not flagged during `pre-commit`
|
|
160
|
+
hooks or CI checks. Nevertheless, ESLint warnings also need to be treated in the
|
|
161
|
+
same way as ESLint errors. It's recommended to review and address them whenever
|
|
162
|
+
feasible. However, if you find that the suggestion does not apply to your
|
|
163
|
+
specific situation, you have the flexibility to disregard it.
|
|
128
164
|
|
|
129
165
|
## Other references
|
|
130
166
|
|
package/dist/index.js
CHANGED
|
@@ -165,6 +165,7 @@
|
|
|
165
165
|
"@bigbinary/neeto/move-spread-attributes-to-top-position": "error",
|
|
166
166
|
"@bigbinary/neeto/prefer-function-reference": "warn",
|
|
167
167
|
"@bigbinary/neeto/jsx-prefer-guard-clause": "warn",
|
|
168
|
+
"@bigbinary/neeto/ensure-usestate-has-initial-value": "error",
|
|
168
169
|
"@bigbinary/neeto/use-show-thumbs-up-toastr": "error"
|
|
169
170
|
};
|
|
170
171
|
|
|
@@ -586,6 +587,7 @@
|
|
|
586
587
|
var JSX_PREFER_GUARD_CLAUSE = "Prefer adding a guard clause for conditional statements left of JSX statments in the last return statement of the function.";
|
|
587
588
|
var USE_SHOW_THUMBS_UP_TOASTR_FUNCTION = "Use 'showThumbsUpToastr' function from '@bigbinary/neeto-commons-frontend/utils' for displaying thumbs up toast message.";
|
|
588
589
|
var NO_UNNECESSARY_CLASSNAMES = "classnames usage is unnecessary";
|
|
590
|
+
var USESTATE_DECLARATIONS_SHOULD_HAVE_INITIAL_VALUE = '"useState" declarations should have an initial value.';
|
|
589
591
|
|
|
590
592
|
var PACKAGES_TO_CHECK = ["@bigbinary/neeto-molecules", "@bigbinary/neetoui", "@bigbinary/neeto-commons-frontend"];
|
|
591
593
|
|
|
@@ -2092,6 +2094,15 @@
|
|
|
2092
2094
|
|
|
2093
2095
|
var _require = require("prettier"),
|
|
2094
2096
|
resolveConfig = _require.resolveConfig;
|
|
2097
|
+
var getPrettierConfig = function getPrettierConfig(fileName) {
|
|
2098
|
+
var options = {
|
|
2099
|
+
useCache: true,
|
|
2100
|
+
editorconfig: true
|
|
2101
|
+
};
|
|
2102
|
+
if (resolveConfig.sync) return resolveConfig.sync(fileName, options);
|
|
2103
|
+
var resolveConfigSync = require("synckit").createSyncFn(require.resolve("./resolveConfigWorker.js"));
|
|
2104
|
+
return resolveConfigSync(fileName, options);
|
|
2105
|
+
};
|
|
2095
2106
|
var ensureCompactObjects = {
|
|
2096
2107
|
meta: {
|
|
2097
2108
|
type: "problem",
|
|
@@ -2102,9 +2113,9 @@
|
|
|
2102
2113
|
fixable: "whitespace"
|
|
2103
2114
|
},
|
|
2104
2115
|
create: function create(context) {
|
|
2116
|
+
var prettierConfig = getPrettierConfig(context.getFilename());
|
|
2105
2117
|
return {
|
|
2106
2118
|
ObjectExpression: function ObjectExpression(node) {
|
|
2107
|
-
var _resolveConfig$sync;
|
|
2108
2119
|
if (isExcludedFile(EXCLUDED_FILES, context.getFilename())) return;
|
|
2109
2120
|
if (!neetoCist.matches(OBJECT_EXPRESSION_PATTERN$1, node)) return;
|
|
2110
2121
|
var sourceCode = context.getSourceCode();
|
|
@@ -2120,10 +2131,7 @@
|
|
|
2120
2131
|
if (/\r|\n/.test(_fix)) return;
|
|
2121
2132
|
var openingBraceColumn = node.loc.start.column;
|
|
2122
2133
|
var closingBraceColumn = node.loc.end.column;
|
|
2123
|
-
var printWidth = (
|
|
2124
|
-
useCache: true,
|
|
2125
|
-
editorconfig: true
|
|
2126
|
-
})) === null || _resolveConfig$sync === void 0 ? void 0 : _resolveConfig$sync.printWidth) || 80;
|
|
2134
|
+
var printWidth = (prettierConfig === null || prettierConfig === void 0 ? void 0 : prettierConfig.printWidth) || 80;
|
|
2127
2135
|
var countOfTokensAfterClosingBrace = sourceCode.lines[closingBraceLine - 1].slice(closingBraceColumn).length;
|
|
2128
2136
|
var resultLength = openingBraceColumn + _fix.length + countOfTokensAfterClosingBrace;
|
|
2129
2137
|
if (resultLength > printWidth - 10) return;
|
|
@@ -2352,6 +2360,36 @@
|
|
|
2352
2360
|
}
|
|
2353
2361
|
};
|
|
2354
2362
|
|
|
2363
|
+
var USESTATE_WITHOUT_ARGUMENTS_PATTERN = {
|
|
2364
|
+
callee: {
|
|
2365
|
+
type: TYPES.IDENTIFIER,
|
|
2366
|
+
name: "useState"
|
|
2367
|
+
},
|
|
2368
|
+
arguments: ramda.isEmpty
|
|
2369
|
+
};
|
|
2370
|
+
|
|
2371
|
+
var ensureUseStateHasInitialValue = {
|
|
2372
|
+
meta: {
|
|
2373
|
+
type: "problem",
|
|
2374
|
+
docs: {
|
|
2375
|
+
url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/ensure-usestate-has-initial-value.md",
|
|
2376
|
+
description: "useState declarations should have an initial value."
|
|
2377
|
+
}
|
|
2378
|
+
},
|
|
2379
|
+
create: function create(context) {
|
|
2380
|
+
return {
|
|
2381
|
+
CallExpression: function CallExpression(node) {
|
|
2382
|
+
if (neetoCist.matches(USESTATE_WITHOUT_ARGUMENTS_PATTERN, node)) {
|
|
2383
|
+
context.report({
|
|
2384
|
+
node: node,
|
|
2385
|
+
message: USESTATE_DECLARATIONS_SHOULD_HAVE_INITIAL_VALUE
|
|
2386
|
+
});
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
};
|
|
2390
|
+
}
|
|
2391
|
+
};
|
|
2392
|
+
|
|
2355
2393
|
const isWindows = typeof process === 'object' &&
|
|
2356
2394
|
process &&
|
|
2357
2395
|
process.platform === 'win32';
|
|
@@ -10662,6 +10700,7 @@
|
|
|
10662
10700
|
"move-spread-attributes-to-top-position": moveSpreadAttributesToTopPosition,
|
|
10663
10701
|
"prefer-function-reference": preferFunctionReference,
|
|
10664
10702
|
"jsx-prefer-guard-clause": jsxPreferGuardClause,
|
|
10703
|
+
"ensure-usestate-has-initial-value": ensureUseStateHasInitialValue,
|
|
10665
10704
|
"use-show-thumbs-up-toastr": useShowThumbsUpToastr
|
|
10666
10705
|
},
|
|
10667
10706
|
configs: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/eslint-plugin-neeto",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"scripts": {
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
|
-
"dist/index.js"
|
|
21
|
+
"dist/index.js",
|
|
22
|
+
"dist/resolveConfigWorker.js"
|
|
22
23
|
],
|
|
23
24
|
"engines": {
|
|
24
25
|
"node": ">=18.12",
|
|
@@ -76,7 +77,9 @@
|
|
|
76
77
|
"rollup": "^2.75.7",
|
|
77
78
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
78
79
|
"rollup-plugin-cleaner": "^1.0.0",
|
|
79
|
-
"rollup-plugin-
|
|
80
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
81
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
82
|
+
"synckit": "^0.9.0"
|
|
80
83
|
},
|
|
81
84
|
"peerDependencies": {
|
|
82
85
|
"@bigbinary/neeto-cist": "latest",
|