@bigbinary/eslint-plugin-neeto 1.5.3 → 1.5.5
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 +1 -0
- package/dist/index.js +58 -25
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -115,6 +115,7 @@ of the issues identified in JavaScript code.
|
|
|
115
115
|
- [use-show-thumbs-up-toastr](./docs/src/rules/use-show-thumbs-up-toastr)
|
|
116
116
|
- [ensure-usestate-has-initial-value](./docs/src/rules/ensure-usestate-has-initial-value.md)
|
|
117
117
|
- [ensure-peer-dependencies-are-in-sync](./docs/src/rules/ensure-peer-dependencies-are-in-sync.md)
|
|
118
|
+
- [use-dayjs-from-neeto-commons-fronted](./docs/src/rules/use-dayjs-from-neeto-commons-fronted.md)
|
|
118
119
|
|
|
119
120
|
### Warnings
|
|
120
121
|
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["@bigbinary/eslint-plugin-neeto"] = factory(global.fs, global.path$2, global.ramda, global["@bigbinary/neeto-cist"], global.neetoCommonsConstants));
|
|
5
5
|
})(this, (function (fs, path$2, ramda, neetoCist, neetoCommonsConstants) { 'use strict';
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
function _interopNamespace(e) {
|
|
10
|
-
if (e && e.__esModule) return e;
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
11
8
|
var n = Object.create(null);
|
|
12
9
|
if (e) {
|
|
13
10
|
Object.keys(e).forEach(function (k) {
|
|
@@ -20,16 +17,14 @@
|
|
|
20
17
|
}
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
|
-
n
|
|
20
|
+
n.default = e;
|
|
24
21
|
return Object.freeze(n);
|
|
25
22
|
}
|
|
26
23
|
|
|
27
|
-
var
|
|
28
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path$2);
|
|
29
|
-
var neetoCommonsConstants__namespace = /*#__PURE__*/_interopNamespace(neetoCommonsConstants);
|
|
24
|
+
var neetoCommonsConstants__namespace = /*#__PURE__*/_interopNamespaceDefault(neetoCommonsConstants);
|
|
30
25
|
|
|
31
26
|
var absolutePath$1 = function absolutePath(jsPath) {
|
|
32
|
-
return
|
|
27
|
+
return path$2.resolve(__dirname, "../../../..", jsPath);
|
|
33
28
|
};
|
|
34
29
|
var loadJS$2 = function loadJS(jsPath) {
|
|
35
30
|
try {
|
|
@@ -42,6 +37,7 @@
|
|
|
42
37
|
var commonResolve$2 = loadJS$2("node_modules/@bigbinary/neeto-commons-frontend/configs/webpack/resolve.js");
|
|
43
38
|
var resolve$2 = ramda.mergeDeepLeft(projectResolve$2, commonResolve$2);
|
|
44
39
|
var rules = {
|
|
40
|
+
"@bigbinary/neeto/use-dayjs-from-neeto-commons-fronted": "error",
|
|
45
41
|
"@bigbinary/neeto/use-neetoui-action-block-in-formik-forms": "warn",
|
|
46
42
|
"@bigbinary/neeto/no-unnecessary-classnames": "error",
|
|
47
43
|
"@bigbinary/neeto/no-snake-case-destructuring-for-use-query-params-and-get-query-params": "warn",
|
|
@@ -184,9 +180,9 @@
|
|
|
184
180
|
};
|
|
185
181
|
|
|
186
182
|
var absolutePath = function absolutePath(jsPath) {
|
|
187
|
-
return
|
|
183
|
+
return path$2.resolve(__dirname, "../../../..", jsPath);
|
|
188
184
|
};
|
|
189
|
-
var srcPath =
|
|
185
|
+
var srcPath = fs.existsSync(absolutePath("src")) ? absolutePath("src") : absolutePath("app/javascript/src");
|
|
190
186
|
var pathToTranslationsDir = "".concat(srcPath, "/translations");
|
|
191
187
|
var pathToResolveFile$1 = "resolve.js";
|
|
192
188
|
var pathToJsConfigFile = "jsconfig.json";
|
|
@@ -256,11 +252,11 @@
|
|
|
256
252
|
}
|
|
257
253
|
});
|
|
258
254
|
|
|
259
|
-
var rootOfTheProject =
|
|
255
|
+
var rootOfTheProject = path$2.join(__dirname, "../../../../");
|
|
260
256
|
var pathToResolveFile = "resolve.js";
|
|
261
257
|
var loadJS = function loadJS(jsPath) {
|
|
262
258
|
try {
|
|
263
|
-
return require(
|
|
259
|
+
return require(path$2.join(rootOfTheProject, jsPath));
|
|
264
260
|
} catch (_unused) {
|
|
265
261
|
return {};
|
|
266
262
|
}
|
|
@@ -498,6 +494,9 @@
|
|
|
498
494
|
var replaceZustandDefaultExportWith = function replaceZustandDefaultExportWith(fix) {
|
|
499
495
|
return "Zustand has deprecated the use of default exports for its functions. Replace this with: ".concat(fix);
|
|
500
496
|
};
|
|
497
|
+
var replaceDayjsDefaultExportWith = function replaceDayjsDefaultExportWith(fix) {
|
|
498
|
+
return "Replace with: ".concat(fix);
|
|
499
|
+
};
|
|
501
500
|
var replaceTailwindClass = function replaceTailwindClass(tailwindClass, neetoUIClass) {
|
|
502
501
|
return "Replace the class \"".concat(tailwindClass, "\" with its neetoui alternative \"").concat(neetoUIClass, "\"");
|
|
503
502
|
};
|
|
@@ -1174,7 +1173,7 @@
|
|
|
1174
1173
|
*/
|
|
1175
1174
|
var isInsideApisDirectory = function isInsideApisDirectory(context) {
|
|
1176
1175
|
var filename = context.getFilename();
|
|
1177
|
-
var apisDirectory =
|
|
1176
|
+
var apisDirectory = path$2.resolve(APIS_DIRECTORY);
|
|
1178
1177
|
return filename.startsWith(apisDirectory) && filename !== "".concat(apisDirectory, "/axios.js");
|
|
1179
1178
|
};
|
|
1180
1179
|
|
|
@@ -1185,7 +1184,7 @@
|
|
|
1185
1184
|
*/
|
|
1186
1185
|
var isInsideComponentsDirectory = function isInsideComponentsDirectory(context) {
|
|
1187
1186
|
var filename = context.getFilename();
|
|
1188
|
-
var componentsDirectory =
|
|
1187
|
+
var componentsDirectory = path$2.resolve(COMPONENTS_DIRECTORY);
|
|
1189
1188
|
return filename.startsWith(componentsDirectory);
|
|
1190
1189
|
};
|
|
1191
1190
|
|
|
@@ -1295,12 +1294,12 @@
|
|
|
1295
1294
|
};
|
|
1296
1295
|
var isExcludedFile = function isExcludedFile(excludedFiles, filename) {
|
|
1297
1296
|
return excludedFiles.some(function (filePath) {
|
|
1298
|
-
return filePath.test(
|
|
1297
|
+
return filePath.test(path$2.resolve(filename));
|
|
1299
1298
|
});
|
|
1300
1299
|
};
|
|
1301
1300
|
var parseJsonData = function parseJsonData(filePath) {
|
|
1302
1301
|
try {
|
|
1303
|
-
var jsonData =
|
|
1302
|
+
var jsonData = fs.readFileSync(filePath).toString();
|
|
1304
1303
|
var parsedJsonData = JSON.parse(removeComments(jsonData));
|
|
1305
1304
|
return parsedJsonData;
|
|
1306
1305
|
} catch (_unused) {
|
|
@@ -7690,7 +7689,7 @@
|
|
|
7690
7689
|
|
|
7691
7690
|
// Do not replace this with `isInsideApisDirectory` since this rule should include axios.js
|
|
7692
7691
|
// `isInsideApisDirectory` returns false for apis/axios.js
|
|
7693
|
-
var apisFolder =
|
|
7692
|
+
var apisFolder = path$2.resolve((aliases === null || aliases === void 0 ? void 0 : aliases.apis) || APIS_DIRECTORY);
|
|
7694
7693
|
if (context.getFilename().startsWith(apisFolder)) return;
|
|
7695
7694
|
if (!isPackageImported(context, node, "axios")) return;
|
|
7696
7695
|
context.report(node, NO_AXIOS_IMPORT_OUTSIDE_APIS_MESSAGE);
|
|
@@ -8911,7 +8910,7 @@
|
|
|
8911
8910
|
}
|
|
8912
8911
|
};
|
|
8913
8912
|
|
|
8914
|
-
function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike
|
|
8913
|
+
function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike) { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
8915
8914
|
function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
|
|
8916
8915
|
function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8917
8916
|
var getNonRepeatedKeyValueProperties = function getNonRepeatedKeyValueProperties(nodeProperties) {
|
|
@@ -10198,7 +10197,7 @@
|
|
|
10198
10197
|
var WHITELISTED_FILE_NAMES = ["constants", "utils"];
|
|
10199
10198
|
|
|
10200
10199
|
var getFolderName = function getFolderName(fileName) {
|
|
10201
|
-
return
|
|
10200
|
+
return path$2.basename(path$2.dirname(fileName));
|
|
10202
10201
|
};
|
|
10203
10202
|
var filesInsideReactQueryFolderShouldEndWithApi = {
|
|
10204
10203
|
meta: {
|
|
@@ -10235,7 +10234,7 @@
|
|
|
10235
10234
|
};
|
|
10236
10235
|
var isInsideReactQueryDirectory = function isInsideReactQueryDirectory(context) {
|
|
10237
10236
|
var filename = context.getFilename();
|
|
10238
|
-
var reactQueryDirectory =
|
|
10237
|
+
var reactQueryDirectory = path$2.resolve(REACT_QUERY_DIRECTORY);
|
|
10239
10238
|
return filename.startsWith(reactQueryDirectory);
|
|
10240
10239
|
};
|
|
10241
10240
|
var useReactQueryForManagingRemoteData = {
|
|
@@ -10325,7 +10324,7 @@
|
|
|
10325
10324
|
}]
|
|
10326
10325
|
};
|
|
10327
10326
|
|
|
10328
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike
|
|
10327
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike) { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
10329
10328
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10330
10329
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10331
10330
|
var extractVariableValue = function extractVariableValue(inputValue) {
|
|
@@ -10938,6 +10937,39 @@
|
|
|
10938
10937
|
}
|
|
10939
10938
|
};
|
|
10940
10939
|
|
|
10940
|
+
var DAYJS_IMPORT_PATTERN = {
|
|
10941
|
+
type: TYPES.IMPORT_DECLARATION,
|
|
10942
|
+
source: {
|
|
10943
|
+
value: "dayjs"
|
|
10944
|
+
}
|
|
10945
|
+
};
|
|
10946
|
+
|
|
10947
|
+
var useDayjsFromNeetoCommonsFronted = {
|
|
10948
|
+
meta: {
|
|
10949
|
+
type: "error",
|
|
10950
|
+
docs: {
|
|
10951
|
+
url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/use-dayjs-from-neeto-commons-fronted.md",
|
|
10952
|
+
description: "Enforce using dayjs from neetocommons/utils."
|
|
10953
|
+
},
|
|
10954
|
+
fixable: "code"
|
|
10955
|
+
},
|
|
10956
|
+
create: function create(context) {
|
|
10957
|
+
return {
|
|
10958
|
+
ImportDeclaration: function ImportDeclaration(node) {
|
|
10959
|
+
if (!neetoCist.matches(DAYJS_IMPORT_PATTERN, node)) return;
|
|
10960
|
+
var _fix = "import { dayjs } from \"neetocommons/utils\";";
|
|
10961
|
+
context.report({
|
|
10962
|
+
node: node,
|
|
10963
|
+
message: replaceDayjsDefaultExportWith(_fix),
|
|
10964
|
+
fix: function fix(fixer) {
|
|
10965
|
+
return fixer.replaceText(node, _fix);
|
|
10966
|
+
}
|
|
10967
|
+
});
|
|
10968
|
+
}
|
|
10969
|
+
};
|
|
10970
|
+
}
|
|
10971
|
+
};
|
|
10972
|
+
|
|
10941
10973
|
var RETURN_STATEMENT_PATTERN = {
|
|
10942
10974
|
type: TYPES.RETURN_STATEMENT
|
|
10943
10975
|
};
|
|
@@ -11007,7 +11039,7 @@
|
|
|
11007
11039
|
var IMAGE_PATH = "images/";
|
|
11008
11040
|
|
|
11009
11041
|
var resolvePath = function resolvePath(relativePath) {
|
|
11010
|
-
return
|
|
11042
|
+
return path$2.resolve(__dirname, "../../../../", relativePath);
|
|
11011
11043
|
};
|
|
11012
11044
|
var isImportFileSvg = function isImportFileSvg(importPath) {
|
|
11013
11045
|
return fs.existsSync(resolvePath("app/assets/".concat(importPath, ".svg")));
|
|
@@ -11946,7 +11978,7 @@
|
|
|
11946
11978
|
var aliases = context.options[0];
|
|
11947
11979
|
if (ramda.isEmpty(aliases) || ramda.isNil(aliases)) return;
|
|
11948
11980
|
var importPath = node.source.value;
|
|
11949
|
-
var importFullPath = importPath.startsWith("../") ?
|
|
11981
|
+
var importFullPath = importPath.startsWith("../") ? path$2.resolve(context.getFilename(), "../", importPath) : importPath;
|
|
11950
11982
|
var matches = Object.entries(aliases).filter(function (_ref) {
|
|
11951
11983
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
11952
11984
|
path = _ref2[1];
|
|
@@ -11973,7 +12005,7 @@
|
|
|
11973
12005
|
var jsconfigData = null;
|
|
11974
12006
|
var watcher = null;
|
|
11975
12007
|
var watchJsConfigFile = function watchJsConfigFile(filePath) {
|
|
11976
|
-
return watcher =
|
|
12008
|
+
return watcher = fs.watch(filePath, {
|
|
11977
12009
|
persistent: false
|
|
11978
12010
|
}, function () {
|
|
11979
12011
|
return jsconfigData = parseJsonData(filePath);
|
|
@@ -12505,6 +12537,7 @@
|
|
|
12505
12537
|
|
|
12506
12538
|
var index = {
|
|
12507
12539
|
rules: {
|
|
12540
|
+
"use-dayjs-from-neeto-commons-fronted": useDayjsFromNeetoCommonsFronted,
|
|
12508
12541
|
"use-neetoui-action-block-in-formik-forms": useNeetouiActionBlockInFormikForms,
|
|
12509
12542
|
"no-unnecessary-classnames": noUnnecessaryClassnames,
|
|
12510
12543
|
"no-snake-case-destructuring-for-use-query-params-and-get-query-params": noSnakeCaseDestructuringForUseQueryParamsAndGetQueryParams,
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/eslint-plugin-neeto",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepare": "husky install",
|
|
8
8
|
"test": "npm run build && jest dist/util-tests.spec.js && node dist/rule-tests.js",
|
|
9
|
-
"build": "rollup -c rollup.config.js",
|
|
10
|
-
"watch": "rollup -c rollup.config.js --watch"
|
|
9
|
+
"build": "rollup --bundleConfigAsCjs -c rollup.config.js",
|
|
10
|
+
"watch": "rollup --bundleConfigAsCjs -c rollup.config.js --watch"
|
|
11
11
|
},
|
|
12
12
|
"lint-staged": {
|
|
13
13
|
"{package.json}": [
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"@bigbinary/neeto-cist": "^1.0.3",
|
|
41
41
|
"@bigbinary/neeto-commons-frontend": "^2.1.29",
|
|
42
42
|
"@rollup/plugin-alias": "^3.1.9",
|
|
43
|
-
"@rollup/plugin-babel": "^
|
|
43
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
44
44
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
45
45
|
"@rollup/plugin-json": "^4.1.0",
|
|
46
|
-
"@rollup/plugin-node-resolve": "^
|
|
46
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
47
47
|
"babel-loader": "^8.2.5",
|
|
48
48
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
49
49
|
"babel-plugin-istanbul": "^6.1.1",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"mock-fs": "^5.2.0",
|
|
75
75
|
"prettier": "2.6.2",
|
|
76
76
|
"ramda": "0.29.0",
|
|
77
|
-
"rollup": "^
|
|
77
|
+
"rollup": "^4.24.0",
|
|
78
78
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
79
79
|
"rollup-plugin-cleaner": "^1.0.0",
|
|
80
80
|
"rollup-plugin-copy": "^3.5.0",
|