@bigbinary/eslint-plugin-neeto 1.3.0 → 1.4.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.
Files changed (3) hide show
  1. package/README.md +53 -17
  2. package/dist/index.js +33 -0
  3. package/package.json +1 -1
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
- - [prefer-function-reference.md](./docs/src/rules/prefer-function-reference.md)
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
- - [use-show-thumbs-up-toastr.md](./docs/src/rules/use-show-thumbs-up-toastr)
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
 
@@ -2352,6 +2354,36 @@
2352
2354
  }
2353
2355
  };
2354
2356
 
2357
+ var USESTATE_WITHOUT_ARGUMENTS_PATTERN = {
2358
+ callee: {
2359
+ type: TYPES.IDENTIFIER,
2360
+ name: "useState"
2361
+ },
2362
+ arguments: ramda.isEmpty
2363
+ };
2364
+
2365
+ var ensureUseStateHasInitialValue = {
2366
+ meta: {
2367
+ type: "problem",
2368
+ docs: {
2369
+ url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/ensure-usestate-has-initial-value.md",
2370
+ description: "useState declarations should have an initial value."
2371
+ }
2372
+ },
2373
+ create: function create(context) {
2374
+ return {
2375
+ CallExpression: function CallExpression(node) {
2376
+ if (neetoCist.matches(USESTATE_WITHOUT_ARGUMENTS_PATTERN, node)) {
2377
+ context.report({
2378
+ node: node,
2379
+ message: USESTATE_DECLARATIONS_SHOULD_HAVE_INITIAL_VALUE
2380
+ });
2381
+ }
2382
+ }
2383
+ };
2384
+ }
2385
+ };
2386
+
2355
2387
  const isWindows = typeof process === 'object' &&
2356
2388
  process &&
2357
2389
  process.platform === 'win32';
@@ -10662,6 +10694,7 @@
10662
10694
  "move-spread-attributes-to-top-position": moveSpreadAttributesToTopPosition,
10663
10695
  "prefer-function-reference": preferFunctionReference,
10664
10696
  "jsx-prefer-guard-clause": jsxPreferGuardClause,
10697
+ "ensure-usestate-has-initial-value": ensureUseStateHasInitialValue,
10665
10698
  "use-show-thumbs-up-toastr": useShowThumbsUpToastr
10666
10699
  },
10667
10700
  configs: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/eslint-plugin-neeto",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {