@bigbinary/eslint-plugin-neeto 1.0.22 → 1.0.23

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 +1 -0
  2. package/dist/index.js +430 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -78,6 +78,7 @@ module.exports = {
78
78
  - [use-react-query-for-managing-remote-data](./docs/src/rules/use-react-query-for-managing-remote-data.md)
79
79
  - [use-snake-case-for-api-connector-filename](./docs/src/rules/use-snake-case-for-api-connector-filename.md)
80
80
  - [use-webpack-alias](./docs/src/rules/use-webpack-alias.md)
81
+ - [use-zustand-for-global-state-management](./docs/src/rules/use-zustand-for-global-state-management.md)
81
82
  - [webpack-aliases-and-jsconfig-paths-should-be-in-sync](./docs/src/rules/webpack-aliases-and-jsconfig-paths-should-be-in-sync.md)
82
83
  - [zustand-recommend-comparator-function-usage](./docs/src/rules/zustand-recommend-comparator-function-usage.md)
83
84
  - [zustand-use-prop-to-pick-single-item](./docs/src/rules/zustand-use-prop-to-pick-single-item.md)
package/dist/index.js CHANGED
@@ -242,6 +242,7 @@
242
242
  "@bigbinary/neeto/use-react-query-for-managing-remote-data": "warn",
243
243
  "@bigbinary/neeto/use-snake-case-for-api-connector-filename": "error",
244
244
  "@bigbinary/neeto/use-webpack-alias": ["error", resolve.alias],
245
+ "@bigbinary/neeto/use-zustand-for-global-state-management": "error",
245
246
  "@bigbinary/neeto/webpack-aliases-and-jsconfig-paths-should-be-in-sync": ["error", {
246
247
  jsconfigFilePath: path$2.resolve(__dirname, "../../../..", "app/javascript/jsconfig.json"),
247
248
  aliasFilePath: path$2.resolve(__dirname, "../../../..", "config/webpack/resolve.js")
@@ -3501,7 +3502,7 @@
3501
3502
 
3502
3503
  function cov_26237ygvis() {
3503
3504
  var path = "/home/runner/work/eslint-plugin-neeto/eslint-plugin-neeto/src/lib/utils/messages.js";
3504
- var hash = "213be830ccef573c3acbb398892f201c57276868";
3505
+ var hash = "d79b2dc96c78e0a1b2011884411a59d2ce915bb9";
3505
3506
  var global = new Function("return this")();
3506
3507
  var gcv = "__coverage__";
3507
3508
  var coverageData = {
@@ -4056,6 +4057,16 @@
4056
4057
  line: 138,
4057
4058
  column: 54
4058
4059
  }
4060
+ },
4061
+ "55": {
4062
+ start: {
4063
+ line: 141,
4064
+ column: 2
4065
+ },
4066
+ end: {
4067
+ line: 141,
4068
+ column: 43
4069
+ }
4059
4070
  }
4060
4071
  },
4061
4072
  fnMap: {
@@ -4356,7 +4367,8 @@
4356
4367
  "51": 0,
4357
4368
  "52": 0,
4358
4369
  "53": 0,
4359
- "54": 0
4370
+ "54": 0,
4371
+ "55": 0
4360
4372
  },
4361
4373
  f: {
4362
4374
  "0": 0,
@@ -4372,7 +4384,7 @@
4372
4384
  },
4373
4385
  b: {},
4374
4386
  _coverageSchema: "1a1c01bbd47fc00a2c39e90264f33305004495a9",
4375
- hash: "213be830ccef573c3acbb398892f201c57276868"
4387
+ hash: "d79b2dc96c78e0a1b2011884411a59d2ce915bb9"
4376
4388
  };
4377
4389
  var coverage = global[gcv] || (global[gcv] = {});
4378
4390
  if (!coverage[path] || coverage[path].hash !== hash) {
@@ -4480,6 +4492,7 @@
4480
4492
  var ENSURE_ZUSTAND_STORES_ARE_TYPE_ANNOTATED = (cov_26237ygvis().s[52]++, "\n Zustand stores should be type annotated like this:\n /** @type {import(\"neetocommons/react-utils\").ZustandStoreHook} */\n const useUserStore = create(...)\n");
4481
4493
  var USE_REACT_QUERY_FOR_MANAGING_REMOTE_DATA = (cov_26237ygvis().s[53]++, "API calls should be managed using React Query");
4482
4494
  var FILES_INSIDE_REACT_QUERY_FOLDER_SHOULD_END_WITH_API = (cov_26237ygvis().s[54]++, "Files inside reactQuery folder should end with Api");
4495
+ var USE_ZUSTAND_FOR_GLOBAL_STATE_MANAGEMENT = (cov_26237ygvis().s[55]++, "Use zustand for global state management");
4483
4496
 
4484
4497
  function cov_22o2x8aeul() {
4485
4498
  var path = "/home/runner/work/eslint-plugin-neeto/eslint-plugin-neeto/src/lib/rules/api-connector-name-should-match-filename.js";
@@ -45712,6 +45725,415 @@
45712
45725
  }
45713
45726
  };
45714
45727
 
45728
+ function cov_2lwg90889() {
45729
+ var path = "/home/runner/work/eslint-plugin-neeto/eslint-plugin-neeto/src/lib/rules/use-zustand-for-global-state-management/constants.js";
45730
+ var hash = "9cd7a0fc9392722b150810e671aa143083795465";
45731
+ var global = new Function("return this")();
45732
+ var gcv = "__coverage__";
45733
+ var coverageData = {
45734
+ path: "/home/runner/work/eslint-plugin-neeto/eslint-plugin-neeto/src/lib/rules/use-zustand-for-global-state-management/constants.js",
45735
+ statementMap: {
45736
+ "0": {
45737
+ start: {
45738
+ line: 7,
45739
+ column: 45
45740
+ },
45741
+ end: {
45742
+ line: 22,
45743
+ column: 1
45744
+ }
45745
+ },
45746
+ "1": {
45747
+ start: {
45748
+ line: 25,
45749
+ column: 38
45750
+ },
45751
+ end: {
45752
+ line: 31,
45753
+ column: 1
45754
+ }
45755
+ },
45756
+ "2": {
45757
+ start: {
45758
+ line: 34,
45759
+ column: 44
45760
+ },
45761
+ end: {
45762
+ line: 47,
45763
+ column: 1
45764
+ }
45765
+ }
45766
+ },
45767
+ fnMap: {},
45768
+ branchMap: {},
45769
+ s: {
45770
+ "0": 0,
45771
+ "1": 0,
45772
+ "2": 0
45773
+ },
45774
+ f: {},
45775
+ b: {},
45776
+ _coverageSchema: "1a1c01bbd47fc00a2c39e90264f33305004495a9",
45777
+ hash: "9cd7a0fc9392722b150810e671aa143083795465"
45778
+ };
45779
+ var coverage = global[gcv] || (global[gcv] = {});
45780
+ if (!coverage[path] || coverage[path].hash !== hash) {
45781
+ coverage[path] = coverageData;
45782
+ }
45783
+ var actualCoverage = coverage[path];
45784
+ {
45785
+ // @ts-ignore
45786
+ cov_2lwg90889 = function () {
45787
+ return actualCoverage;
45788
+ };
45789
+ }
45790
+ return actualCoverage;
45791
+ }
45792
+ cov_2lwg90889();
45793
+
45794
+ // import { createContext } from "react"
45795
+ var CREATE_CONTEXT_IMPORT_PATTERN = (cov_2lwg90889().s[0]++, {
45796
+ type: TYPES.IMPORT_DECLARATION,
45797
+ source: {
45798
+ type: TYPES.LITERAL,
45799
+ value: "react"
45800
+ },
45801
+ specifiers: ramda.any(matches({
45802
+ type: TYPES.IMPORT_SPECIFIER,
45803
+ imported: {
45804
+ type: TYPES.IDENTIFIER,
45805
+ name: "createContext"
45806
+ }
45807
+ }))
45808
+ });
45809
+
45810
+ // createContext()
45811
+ var CREATE_CONTEXT_PATTERN = (cov_2lwg90889().s[1]++, {
45812
+ type: TYPES.CALL_EXPRESSION,
45813
+ callee: {
45814
+ type: TYPES.IDENTIFIER,
45815
+ name: "createContext"
45816
+ }
45817
+ });
45818
+
45819
+ // React.createContext()
45820
+ var REACT_CREATE_CONTEXT_PATTERN = (cov_2lwg90889().s[2]++, {
45821
+ type: TYPES.CALL_EXPRESSION,
45822
+ callee: {
45823
+ type: TYPES.MEMBER_EXPRESSION,
45824
+ object: {
45825
+ type: TYPES.IDENTIFIER,
45826
+ name: "React"
45827
+ },
45828
+ property: {
45829
+ type: TYPES.IDENTIFIER,
45830
+ name: "createContext"
45831
+ }
45832
+ }
45833
+ });
45834
+
45835
+ function cov_2lma74dae4() {
45836
+ var path = "/home/runner/work/eslint-plugin-neeto/eslint-plugin-neeto/src/lib/rules/use-zustand-for-global-state-management/index.js";
45837
+ var hash = "047a5a773ef31d8879075cd89678b476b88a6df9";
45838
+ var global = new Function("return this")();
45839
+ var gcv = "__coverage__";
45840
+ var coverageData = {
45841
+ path: "/home/runner/work/eslint-plugin-neeto/eslint-plugin-neeto/src/lib/rules/use-zustand-for-global-state-management/index.js",
45842
+ statementMap: {
45843
+ "0": {
45844
+ start: {
45845
+ line: 11,
45846
+ column: 28
45847
+ },
45848
+ end: {
45849
+ line: 16,
45850
+ column: 1
45851
+ }
45852
+ },
45853
+ "1": {
45854
+ start: {
45855
+ line: 12,
45856
+ column: 15
45857
+ },
45858
+ end: {
45859
+ line: 12,
45860
+ column: 40
45861
+ }
45862
+ },
45863
+ "2": {
45864
+ start: {
45865
+ line: 13,
45866
+ column: 24
45867
+ },
45868
+ end: {
45869
+ line: 13,
45870
+ column: 78
45871
+ }
45872
+ },
45873
+ "3": {
45874
+ start: {
45875
+ line: 15,
45876
+ column: 2
45877
+ },
45878
+ end: {
45879
+ line: 15,
45880
+ column: 23
45881
+ }
45882
+ },
45883
+ "4": {
45884
+ start: {
45885
+ line: 25,
45886
+ column: 22
45887
+ },
45888
+ end: {
45889
+ line: 37,
45890
+ column: 3
45891
+ }
45892
+ },
45893
+ "5": {
45894
+ start: {
45895
+ line: 27,
45896
+ column: 6
45897
+ },
45898
+ end: {
45899
+ line: 35,
45900
+ column: 7
45901
+ }
45902
+ },
45903
+ "6": {
45904
+ start: {
45905
+ line: 31,
45906
+ column: 8
45907
+ },
45908
+ end: {
45909
+ line: 34,
45910
+ column: 11
45911
+ }
45912
+ }
45913
+ },
45914
+ fnMap: {
45915
+ "0": {
45916
+ name: "(anonymous_0)",
45917
+ decl: {
45918
+ start: {
45919
+ line: 11,
45920
+ column: 28
45921
+ },
45922
+ end: {
45923
+ line: 11,
45924
+ column: 29
45925
+ }
45926
+ },
45927
+ loc: {
45928
+ start: {
45929
+ line: 11,
45930
+ column: 39
45931
+ },
45932
+ end: {
45933
+ line: 16,
45934
+ column: 1
45935
+ }
45936
+ },
45937
+ line: 11
45938
+ },
45939
+ "1": {
45940
+ name: "(anonymous_1)",
45941
+ decl: {
45942
+ start: {
45943
+ line: 25,
45944
+ column: 10
45945
+ },
45946
+ end: {
45947
+ line: 25,
45948
+ column: 11
45949
+ }
45950
+ },
45951
+ loc: {
45952
+ start: {
45953
+ line: 25,
45954
+ column: 22
45955
+ },
45956
+ end: {
45957
+ line: 37,
45958
+ column: 3
45959
+ }
45960
+ },
45961
+ line: 25
45962
+ },
45963
+ "2": {
45964
+ name: "(anonymous_2)",
45965
+ decl: {
45966
+ start: {
45967
+ line: 26,
45968
+ column: 4
45969
+ },
45970
+ end: {
45971
+ line: 26,
45972
+ column: 5
45973
+ }
45974
+ },
45975
+ loc: {
45976
+ start: {
45977
+ line: 26,
45978
+ column: 25
45979
+ },
45980
+ end: {
45981
+ line: 36,
45982
+ column: 5
45983
+ }
45984
+ },
45985
+ line: 26
45986
+ }
45987
+ },
45988
+ branchMap: {
45989
+ "0": {
45990
+ loc: {
45991
+ start: {
45992
+ line: 27,
45993
+ column: 6
45994
+ },
45995
+ end: {
45996
+ line: 35,
45997
+ column: 7
45998
+ }
45999
+ },
46000
+ type: "if",
46001
+ locations: [{
46002
+ start: {
46003
+ line: 27,
46004
+ column: 6
46005
+ },
46006
+ end: {
46007
+ line: 35,
46008
+ column: 7
46009
+ }
46010
+ }, {
46011
+ start: {
46012
+ line: undefined,
46013
+ column: undefined
46014
+ },
46015
+ end: {
46016
+ line: undefined,
46017
+ column: undefined
46018
+ }
46019
+ }],
46020
+ line: 27
46021
+ },
46022
+ "1": {
46023
+ loc: {
46024
+ start: {
46025
+ line: 28,
46026
+ column: 8
46027
+ },
46028
+ end: {
46029
+ line: 29,
46030
+ column: 79
46031
+ }
46032
+ },
46033
+ type: "binary-expr",
46034
+ locations: [{
46035
+ start: {
46036
+ line: 28,
46037
+ column: 8
46038
+ },
46039
+ end: {
46040
+ line: 28,
46041
+ column: 51
46042
+ }
46043
+ }, {
46044
+ start: {
46045
+ line: 29,
46046
+ column: 9
46047
+ },
46048
+ end: {
46049
+ line: 29,
46050
+ column: 46
46051
+ }
46052
+ }, {
46053
+ start: {
46054
+ line: 29,
46055
+ column: 50
46056
+ },
46057
+ end: {
46058
+ line: 29,
46059
+ column: 78
46060
+ }
46061
+ }],
46062
+ line: 28
46063
+ }
46064
+ },
46065
+ s: {
46066
+ "0": 0,
46067
+ "1": 0,
46068
+ "2": 0,
46069
+ "3": 0,
46070
+ "4": 0,
46071
+ "5": 0,
46072
+ "6": 0
46073
+ },
46074
+ f: {
46075
+ "0": 0,
46076
+ "1": 0,
46077
+ "2": 0
46078
+ },
46079
+ b: {
46080
+ "0": [0, 0],
46081
+ "1": [0, 0, 0]
46082
+ },
46083
+ _coverageSchema: "1a1c01bbd47fc00a2c39e90264f33305004495a9",
46084
+ hash: "047a5a773ef31d8879075cd89678b476b88a6df9"
46085
+ };
46086
+ var coverage = global[gcv] || (global[gcv] = {});
46087
+ if (!coverage[path] || coverage[path].hash !== hash) {
46088
+ coverage[path] = coverageData;
46089
+ }
46090
+ var actualCoverage = coverage[path];
46091
+ {
46092
+ // @ts-ignore
46093
+ cov_2lma74dae4 = function () {
46094
+ return actualCoverage;
46095
+ };
46096
+ }
46097
+ return actualCoverage;
46098
+ }
46099
+ cov_2lma74dae4();
46100
+ cov_2lma74dae4().s[0]++;
46101
+ var isImportedFromReact = function isImportedFromReact(context) {
46102
+ cov_2lma74dae4().f[0]++;
46103
+ var root = (cov_2lma74dae4().s[1]++, context.getAncestors()[0]);
46104
+ var isImportExist = (cov_2lma74dae4().s[2]++, root.body.some(matches(CREATE_CONTEXT_IMPORT_PATTERN)));
46105
+ cov_2lma74dae4().s[3]++;
46106
+ return isImportExist;
46107
+ };
46108
+ var useZustandForGlobalStateManagement = {
46109
+ meta: {
46110
+ type: "problem",
46111
+ docs: {
46112
+ description: "Use zustand for global state management"
46113
+ }
46114
+ },
46115
+ create: function create(context) {
46116
+ cov_2lma74dae4().f[1]++;
46117
+ cov_2lma74dae4().s[4]++;
46118
+ return {
46119
+ CallExpression: function CallExpression(node) {
46120
+ cov_2lma74dae4().f[2]++;
46121
+ cov_2lma74dae4().s[5]++;
46122
+ if ((cov_2lma74dae4().b[1][0]++, matches(REACT_CREATE_CONTEXT_PATTERN, node)) || (cov_2lma74dae4().b[1][1]++, matches(CREATE_CONTEXT_PATTERN, node)) && (cov_2lma74dae4().b[1][2]++, isImportedFromReact(context))) {
46123
+ cov_2lma74dae4().b[0][0]++;
46124
+ cov_2lma74dae4().s[6]++;
46125
+ context.report({
46126
+ node: node,
46127
+ message: USE_ZUSTAND_FOR_GLOBAL_STATE_MANAGEMENT
46128
+ });
46129
+ } else {
46130
+ cov_2lma74dae4().b[0][1]++;
46131
+ }
46132
+ }
46133
+ };
46134
+ }
46135
+ };
46136
+
45715
46137
  function cov_1qf21ie77k() {
45716
46138
  var path = "/home/runner/work/eslint-plugin-neeto/eslint-plugin-neeto/src/lib/rules/webpack-aliases-and-jsconfig-paths-should-be-in-sync.js";
45717
46139
  var hash = "1984a9fc673a0378e65f1b8826a304ab3d953c43";
@@ -47970,13 +48392,14 @@
47970
48392
  cov_1cnpbb28xs();
47971
48393
  var index = {
47972
48394
  rules: {
47973
- "minimize-zustand-store-access-scope": minimizeZustandStoreAccessScope,
47974
48395
  "api-connector-name-should-match-filename": apiConnectorNameShouldMatchFilename,
47975
48396
  "api-connector-should-use-default-export": apiConnectorShouldUseDefaultExport,
47976
48397
  "combine-multiple-independent-awaits": combineMultipleIndependentAwaits,
47977
48398
  "consistent-button-link-anchor": consistentButtonLinkAnchor,
47978
48399
  "ensure-zustand-stores-are-type-annotated": ensureZustandStoresAreTypeAnnotated,
48400
+ "files-inside-react-query-folder-should-end-with-api": filesInsideReactQueryFolderShouldEndWithApi,
47979
48401
  "file-name-and-export-name-standards": fileNameAndExportNameStandards,
48402
+ "minimize-zustand-store-access-scope": minimizeZustandStoreAccessScope,
47980
48403
  "neetocommons-tips": neetocommonsTips,
47981
48404
  "no-blacklisted-imports": noBlacklistedImports,
47982
48405
  "no-axios-import-outside-apis": noAxiosImportOutsideApis,
@@ -47998,13 +48421,13 @@
47998
48421
  "use-axios-config-for-passing-query-parameters": useAxiosConfigForPassingQueryParameters,
47999
48422
  "use-common-routes": useCommonRoutes,
48000
48423
  "use-neetoui-classes": useNeetouiClasses,
48424
+ "use-react-query-for-managing-remote-data": useReactQueryForManagingRemoteData,
48001
48425
  "use-snake-case-for-api-connector-filename": useSnakeCaseForApiConnectorFilename,
48002
48426
  "use-webpack-alias": useWebpackAlias,
48427
+ "use-zustand-for-global-state-management": useZustandForGlobalStateManagement,
48003
48428
  "webpack-aliases-and-jsconfig-paths-should-be-in-sync": webpackAliasesAndJsconfigPathsShouldBeInSync,
48004
48429
  "zustand-recommend-comparator-function-usage": zustandRecommendComparatorFunctionUsage,
48005
- "zustand-use-prop-to-pick-single-item": zustandUsePropToPickSingleItem,
48006
- "files-inside-react-query-folder-should-end-with-api": filesInsideReactQueryFolderShouldEndWithApi,
48007
- "use-react-query-for-managing-remote-data": useReactQueryForManagingRemoteData
48430
+ "zustand-use-prop-to-pick-single-item": zustandUsePropToPickSingleItem
48008
48431
  },
48009
48432
  configs: {
48010
48433
  recommended: recommended
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/eslint-plugin-neeto",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "main": "dist/index.js",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {