@bigbinary/eslint-plugin-neeto 1.0.16 → 1.0.18
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 +19 -3
- package/dist/index.js +107 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,11 +8,27 @@ neeto.
|
|
|
8
8
|
Install the plugin from npm:
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
yarn add -D "@bigbinary/eslint-plugin-neeto@1.0.
|
|
11
|
+
yarn add -D "@bigbinary/eslint-plugin-neeto@1.0.18"
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
In your eslintrc.js file, add `neeto` in the `plugins` list and add the
|
|
15
|
-
|
|
14
|
+
In your eslintrc.js file, add `neeto` in the `plugins` list and add the
|
|
15
|
+
configuration 'recommended' in extends with prefix as 'plugin:'.
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
module.exports = {
|
|
19
|
+
// ...other configurations
|
|
20
|
+
plugins: [
|
|
21
|
+
// ...other plugins
|
|
22
|
+
"@bigbinary/neeto",
|
|
23
|
+
],
|
|
24
|
+
extends: [
|
|
25
|
+
"plugin:@bigbinary/neeto/recommended",
|
|
26
|
+
// ...other plugins/extensions
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Optionally, if you don't need all the recommended rules, follow this approach:
|
|
16
32
|
|
|
17
33
|
```js
|
|
18
34
|
module.exports = {
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,107 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('path'), require('ramda'), require('fs')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['path', 'ramda', 'fs'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["@bigbinary/eslint-plugin-neeto"] = factory(global.path$
|
|
5
|
-
})(this, (function (path$
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["@bigbinary/eslint-plugin-neeto"] = factory(global.path$3, global.ramda, global.fs));
|
|
5
|
+
})(this, (function (path$3, ramda, fs) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path$
|
|
9
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path$3);
|
|
10
10
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
11
11
|
|
|
12
|
+
const path$2 = require("path");
|
|
13
|
+
|
|
14
|
+
const webpackAliasConfig = require(path$2.resolve(__dirname, "../../../..", "config/webpack/resolve.js"));
|
|
15
|
+
|
|
16
|
+
var rules = {
|
|
17
|
+
"@bigbinary/neeto/api-connector-name-should-match-filename": "error",
|
|
18
|
+
"@bigbinary/neeto/api-connector-should-use-default-export": "error",
|
|
19
|
+
"@bigbinary/neeto/combine-multiple-independent-awaits": "warn",
|
|
20
|
+
"@bigbinary/neeto/consistent-button-link-anchor": "warn",
|
|
21
|
+
"@bigbinary/neeto/ensure-zustand-import-names-are-consistent": "error",
|
|
22
|
+
"@bigbinary/neeto/ensure-zustand-stores-are-type-annotated": "error",
|
|
23
|
+
"@bigbinary/neeto/file-name-and-export-name-standards": ["warn", {
|
|
24
|
+
basePath: path$2.resolve(__dirname, "../../../..", "app/javascript/src"),
|
|
25
|
+
default: {
|
|
26
|
+
filenameCase: "camelCase",
|
|
27
|
+
exportnameCase: "camelCase"
|
|
28
|
+
},
|
|
29
|
+
configs: [{
|
|
30
|
+
filenameCase: "camelCase",
|
|
31
|
+
exportnameCase: "CONSTANT_CASE",
|
|
32
|
+
includes: ["/**/constants.{js,jsx}", "/**/constants/**"]
|
|
33
|
+
}, {
|
|
34
|
+
filenameCase: "camelCase",
|
|
35
|
+
includes: ["/**/utils.{js,jsx}", "/**/utils/**"]
|
|
36
|
+
}, {
|
|
37
|
+
filenameCase: "snake_case",
|
|
38
|
+
exportnameCase: "camelCase",
|
|
39
|
+
includes: "/apis/**"
|
|
40
|
+
}, {
|
|
41
|
+
filenameCase: "camelCase",
|
|
42
|
+
exportnameCase: "camelCase",
|
|
43
|
+
includes: "/channels/**"
|
|
44
|
+
}, {
|
|
45
|
+
filenameCase: "camelCase",
|
|
46
|
+
exportnameCase: "camelCase",
|
|
47
|
+
includes: "/**/hooks/**"
|
|
48
|
+
}, {
|
|
49
|
+
filenameCase: "camelCase",
|
|
50
|
+
includes: "/lib/**"
|
|
51
|
+
}, {
|
|
52
|
+
filenameCase: "camelCase",
|
|
53
|
+
exportnameCase: "camelCase",
|
|
54
|
+
includes: "/**/stores/**"
|
|
55
|
+
}, {
|
|
56
|
+
filenameCase: "PascalCase",
|
|
57
|
+
exportnameCase: "PascalCase",
|
|
58
|
+
includes: ["/components/**", "/*.jsx"]
|
|
59
|
+
}]
|
|
60
|
+
}],
|
|
61
|
+
"@bigbinary/neeto/neetocommons-tips": "warn",
|
|
62
|
+
"@bigbinary/neeto/no-axios-import-outside-apis": ["error", webpackAliasConfig.alias],
|
|
63
|
+
"@bigbinary/neeto/no-blacklisted-imports": "warn",
|
|
64
|
+
"@bigbinary/neeto/no-dangling-constants": "error",
|
|
65
|
+
"@bigbinary/neeto/no-excess-function-arguments": "warn",
|
|
66
|
+
"@bigbinary/neeto/no-globalProps-destructure": "error",
|
|
67
|
+
"@bigbinary/neeto/no-globalProps-reassignment": "error",
|
|
68
|
+
"@bigbinary/neeto/no-missing-localization": ["error", {
|
|
69
|
+
name: "en.json",
|
|
70
|
+
lng: "en",
|
|
71
|
+
content: require(path$2.resolve(__dirname, "../../../..", "app/javascript/src/translations/en.json"))
|
|
72
|
+
}],
|
|
73
|
+
"@bigbinary/neeto/no-namespace-specifier-import-for-ramda": "error",
|
|
74
|
+
"@bigbinary/neeto/no-redundant-jsx-expression": "error",
|
|
75
|
+
"@bigbinary/neeto/no-redundant-string-templates": "error",
|
|
76
|
+
"@bigbinary/neeto/no-routes-destructure-and-reassignment": "error",
|
|
77
|
+
"@bigbinary/neeto/prefix-neeto-ui-import-alias": ["error", webpackAliasConfig.alias],
|
|
78
|
+
"@bigbinary/neeto/ramda-tips": "warn",
|
|
79
|
+
"@bigbinary/neeto/routes-should-be-declared-and-default-exported": "error",
|
|
80
|
+
"@bigbinary/neeto/routes-should-match-object-path": "error",
|
|
81
|
+
"@bigbinary/neeto/use-axios-config-for-passing-query-parameters": "warn",
|
|
82
|
+
"@bigbinary/neeto/use-common-routes": "error",
|
|
83
|
+
"@bigbinary/neeto/use-snake-case-for-api-connector-filename": "error",
|
|
84
|
+
"@bigbinary/neeto/use-webpack-alias": ["error", webpackAliasConfig.alias],
|
|
85
|
+
"@bigbinary/neeto/webpack-aliases-and-jsconfig-paths-should-be-in-sync": ["error", {
|
|
86
|
+
jsconfigFilePath: path$2.resolve(__dirname, "../../../..", "app/javascript/jsconfig.json"),
|
|
87
|
+
aliasFilePath: path$2.resolve(__dirname, "../../../..", "config/webpack/resolve.js")
|
|
88
|
+
}],
|
|
89
|
+
"@bigbinary/neeto/zustand-recommend-comparator-function-usage": "warn",
|
|
90
|
+
"@bigbinary/neeto/zustand-use-prop-to-pick-single-item": "error"
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
var recommended = {
|
|
94
|
+
plugins: ["@bigbinary/neeto"],
|
|
95
|
+
env: {
|
|
96
|
+
browser: true,
|
|
97
|
+
es2020: true,
|
|
98
|
+
es6: true,
|
|
99
|
+
commonjs: true,
|
|
100
|
+
node: true
|
|
101
|
+
},
|
|
102
|
+
rules
|
|
103
|
+
};
|
|
104
|
+
|
|
12
105
|
function _arrayWithHoles(arr) {
|
|
13
106
|
if (Array.isArray(arr)) return arr;
|
|
14
107
|
}
|
|
@@ -175,7 +268,7 @@
|
|
|
175
268
|
});
|
|
176
269
|
|
|
177
270
|
const APIS_DIRECTORY = "app/javascript/src/apis";
|
|
178
|
-
const
|
|
271
|
+
const ROUTES_FILE_PATH = "app/javascript/src/routes.js";
|
|
179
272
|
const BLACKLISTED_PACKAGES = ["moment", "bootstrap", "blueprint", "react-spinners", "react-table", "remixicon", "mjml", "react-select", "antd", "@bigbinary/neeto-utils"];
|
|
180
273
|
const TYPES = {
|
|
181
274
|
ARRAY_EXPRESSION: "ArrayExpression",
|
|
@@ -615,13 +708,13 @@
|
|
|
615
708
|
})
|
|
616
709
|
};
|
|
617
710
|
|
|
618
|
-
const SPECIAL_KEYS = ["home", "index", "show"]; // import routes from "routes"
|
|
711
|
+
const SPECIAL_KEYS = ["home", "index", "show"]; // import routes from "routes", import routes from "src/routes"
|
|
619
712
|
|
|
620
713
|
const ROUTES_IMPORT_PATTERN = {
|
|
621
714
|
type: TYPES.IMPORT_DECLARATION,
|
|
622
715
|
source: {
|
|
623
716
|
type: TYPES.LITERAL,
|
|
624
|
-
value: matchesAny(["routes", "src/routes"
|
|
717
|
+
value: matchesAny(["routes", "src/routes"])
|
|
625
718
|
},
|
|
626
719
|
specifiers: [{
|
|
627
720
|
type: TYPES.IMPORT_DEFAULT_SPECIFIER,
|
|
@@ -786,7 +879,7 @@
|
|
|
786
879
|
|
|
787
880
|
const isInsideRoutesFile$1 = context => {
|
|
788
881
|
const filename = context.getFilename();
|
|
789
|
-
return
|
|
882
|
+
return filename.endsWith(ROUTES_FILE_PATH);
|
|
790
883
|
};
|
|
791
884
|
|
|
792
885
|
var routesShouldBeDeclaredAndDefaultExported = {
|
|
@@ -820,7 +913,7 @@
|
|
|
820
913
|
|
|
821
914
|
const isInsideRoutesFile = context => {
|
|
822
915
|
const filename = context.getFilename();
|
|
823
|
-
return
|
|
916
|
+
return filename.endsWith(ROUTES_FILE_PATH);
|
|
824
917
|
};
|
|
825
918
|
|
|
826
919
|
const isParam = e => e === null || e === void 0 ? void 0 : e.startsWith(":");
|
|
@@ -1130,7 +1223,7 @@
|
|
|
1130
1223
|
};
|
|
1131
1224
|
|
|
1132
1225
|
const CONSTANT_CASE_PATTERN = /^[A-Z0-9_]*$/;
|
|
1133
|
-
const CONSTANTS_FILES = [/constants\//, /.*constants.(js|jsx)$/i
|
|
1226
|
+
const CONSTANTS_FILES = [/constants\//, /.*constants.(js|jsx)$/i];
|
|
1134
1227
|
const CONSTANT_DECALARATION_PATTERN = {
|
|
1135
1228
|
kind: "const",
|
|
1136
1229
|
declarations: [{
|
|
@@ -1281,7 +1374,7 @@
|
|
|
1281
1374
|
}];
|
|
1282
1375
|
const TYPE_ANNOTATION_COMMENT_PATTERN = [{
|
|
1283
1376
|
type: "Block",
|
|
1284
|
-
value:
|
|
1377
|
+
value: '* @type {import("neetocommons/react-utils").ZustandStoreHook} '
|
|
1285
1378
|
}]; // .....
|
|
1286
1379
|
// const useCurrentUserStore = create(....);
|
|
1287
1380
|
|
|
@@ -2493,7 +2586,7 @@
|
|
|
2493
2586
|
var minimatch$1 = minimatch_1;
|
|
2494
2587
|
|
|
2495
2588
|
const CAMEL_CASE_REGEX = /^[a-z][A-Za-z0-9]*$/;
|
|
2496
|
-
const CONSTANT_CASE_REGEX = /^[A-
|
|
2589
|
+
const CONSTANT_CASE_REGEX = /^[A-Z0-9_]+$/;
|
|
2497
2590
|
const PASCAL_CASE_REGEX = /^[A-Z][A-Za-z0-9]*$/;
|
|
2498
2591
|
const SNAKE_CASE_REGEX$1 = /^[a-z0-9_]+$/;
|
|
2499
2592
|
const EXPORT_PATTERN = {
|
|
@@ -5582,6 +5675,9 @@
|
|
|
5582
5675
|
"webpack-aliases-and-jsconfig-paths-should-be-in-sync": webpackAliasesAndJsconfigPathsShouldBeInSync,
|
|
5583
5676
|
"zustand-recommend-comparator-function-usage": zustandRecommendComparatorFunctionUsage,
|
|
5584
5677
|
"zustand-use-prop-to-pick-single-item": zustandUsePropToPickSingleItem
|
|
5678
|
+
},
|
|
5679
|
+
configs: {
|
|
5680
|
+
recommended
|
|
5585
5681
|
}
|
|
5586
5682
|
};
|
|
5587
5683
|
|