@bigbinary/eslint-plugin-neeto 1.5.8 → 1.6.1
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/dist/index.js +285 -49
- package/package.json +17 -17
package/dist/index.js
CHANGED
|
@@ -274,8 +274,120 @@
|
|
|
274
274
|
}
|
|
275
275
|
});
|
|
276
276
|
|
|
277
|
+
var name = "@bigbinary/eslint-plugin-neeto";
|
|
278
|
+
var version = "1.6.0";
|
|
279
|
+
var main = "dist/index.js";
|
|
280
|
+
var license = "UNLICENSED";
|
|
281
|
+
var scripts = {
|
|
282
|
+
prepare: "husky install",
|
|
283
|
+
test: "npm run build && jest dist/util-tests.spec.js && node dist/rule-tests.js",
|
|
284
|
+
build: "rollup --bundleConfigAsCjs -c rollup.config.js",
|
|
285
|
+
watch: "rollup --bundleConfigAsCjs -c rollup.config.js --watch"
|
|
286
|
+
};
|
|
287
|
+
var files = [
|
|
288
|
+
"dist/index.js",
|
|
289
|
+
"dist/resolveConfigWorker.js"
|
|
290
|
+
];
|
|
291
|
+
var engines = {
|
|
292
|
+
node: ">=22.13",
|
|
293
|
+
npm: ">=9",
|
|
294
|
+
yarn: ">=1.22"
|
|
295
|
+
};
|
|
296
|
+
var dependencies = {
|
|
297
|
+
};
|
|
298
|
+
var devDependencies = {
|
|
299
|
+
"@babel/core": "^7.19.1",
|
|
300
|
+
"@babel/eslint-parser": "7.17.0",
|
|
301
|
+
"@babel/plugin-transform-runtime": "^7.19.1",
|
|
302
|
+
"@babel/preset-env": "7.17.10",
|
|
303
|
+
"@babel/preset-react": "7.16.7",
|
|
304
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
305
|
+
"@babel/runtime": "^7.19.0",
|
|
306
|
+
"@bigbinary/babel-preset-neeto": "^1.0.3",
|
|
307
|
+
"@bigbinary/eslint-plugin-neeto": "1.5.5",
|
|
308
|
+
"@bigbinary/neeto-cist": "^1.0.3",
|
|
309
|
+
"@bigbinary/neeto-commons-frontend": "^4.13.35",
|
|
310
|
+
"@rollup/plugin-alias": "^3.1.9",
|
|
311
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
312
|
+
"@rollup/plugin-commonjs": "^22.0.0",
|
|
313
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
314
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
315
|
+
"babel-loader": "^8.2.5",
|
|
316
|
+
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
317
|
+
"babel-plugin-istanbul": "^6.1.1",
|
|
318
|
+
"babel-plugin-js-logger": "1.0.17",
|
|
319
|
+
"babel-plugin-macros": "3.1.0",
|
|
320
|
+
"babel-plugin-module-resolver": "^5.0.0",
|
|
321
|
+
"babel-plugin-preval": "^5.1.0",
|
|
322
|
+
"babel-plugin-transform-imports": "^2.0.0",
|
|
323
|
+
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
|
|
324
|
+
"babel-preset-react": "6.24.1",
|
|
325
|
+
"babel-preset-typescript": "^7.0.0-alpha.19",
|
|
326
|
+
cheerio: "^1.0.0-rc.12",
|
|
327
|
+
"command-line-args": "^5.2.1",
|
|
328
|
+
eslint: "^9.25.1",
|
|
329
|
+
"eslint-config-prettier": "^10.1.2",
|
|
330
|
+
"eslint-plugin-cypress": "^4.3.0",
|
|
331
|
+
"eslint-plugin-import": "^2.31.0",
|
|
332
|
+
"eslint-plugin-jam3": "^0.2.3",
|
|
333
|
+
"eslint-plugin-json": "^4.0.1",
|
|
334
|
+
"eslint-plugin-prettier": "^5.2.6",
|
|
335
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
336
|
+
"eslint-plugin-react": "^7.37.5",
|
|
337
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
338
|
+
"eslint-plugin-security": "^3.0.1",
|
|
339
|
+
"eslint-plugin-sonarjs": "^3.0.2",
|
|
340
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
341
|
+
globals: "^16.0.0",
|
|
342
|
+
husky: "7.0.4",
|
|
343
|
+
i18next: "21.7.0",
|
|
344
|
+
jest: "27.5.1",
|
|
345
|
+
"lint-staged": "12.4.1",
|
|
346
|
+
minimatch: "^5.1.0",
|
|
347
|
+
"mock-fs": "^5.2.0",
|
|
348
|
+
prettier: "2.6.2",
|
|
349
|
+
ramda: "0.29.0",
|
|
350
|
+
rollup: "^4.24.0",
|
|
351
|
+
"rollup-plugin-analyzer": "^4.0.0",
|
|
352
|
+
"rollup-plugin-cleaner": "^1.0.0",
|
|
353
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
354
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
355
|
+
synckit: "^0.9.0"
|
|
356
|
+
};
|
|
357
|
+
var peerDependencies = {
|
|
358
|
+
"@bigbinary/neeto-cist": "^1.0.3",
|
|
359
|
+
"@bigbinary/neeto-commons-frontend": "4.12.3",
|
|
360
|
+
eslint: "^9.25.1",
|
|
361
|
+
i18next: "21.7.0",
|
|
362
|
+
ramda: "0.29.0"
|
|
363
|
+
};
|
|
364
|
+
var packageJson = {
|
|
365
|
+
name: name,
|
|
366
|
+
version: version,
|
|
367
|
+
main: main,
|
|
368
|
+
license: license,
|
|
369
|
+
scripts: scripts,
|
|
370
|
+
"lint-staged": {
|
|
371
|
+
"{package.json}": [
|
|
372
|
+
".scripts/fix-lints.sh"
|
|
373
|
+
],
|
|
374
|
+
"**/*.js": [
|
|
375
|
+
".scripts/fix-lints.sh"
|
|
376
|
+
]
|
|
377
|
+
},
|
|
378
|
+
files: files,
|
|
379
|
+
engines: engines,
|
|
380
|
+
dependencies: dependencies,
|
|
381
|
+
devDependencies: devDependencies,
|
|
382
|
+
peerDependencies: peerDependencies
|
|
383
|
+
};
|
|
384
|
+
|
|
277
385
|
const prefix = "export default ";
|
|
278
386
|
var jsonProcessor = {
|
|
387
|
+
meta: {
|
|
388
|
+
name: "eslint-processor-json-for-neeto",
|
|
389
|
+
version: packageJson.version
|
|
390
|
+
},
|
|
279
391
|
_prefix: prefix,
|
|
280
392
|
preprocess(text) {
|
|
281
393
|
return [`${prefix}${text}`];
|
|
@@ -615,13 +727,14 @@
|
|
|
615
727
|
});
|
|
616
728
|
|
|
617
729
|
const removeComments = json => json.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => g ? "" : m);
|
|
618
|
-
const addNullSafeImport = (context, fixer) => {
|
|
730
|
+
const addNullSafeImport = (context, fixer, node) => {
|
|
619
731
|
const importPattern = ramda.assocPath(["source", "value"], "neetocist", IMPORT_DECLARATION);
|
|
620
732
|
return addFunctionImport({
|
|
621
733
|
context,
|
|
622
734
|
fixer,
|
|
623
735
|
functions: ["nullSafe"],
|
|
624
|
-
importPattern
|
|
736
|
+
importPattern,
|
|
737
|
+
node
|
|
625
738
|
});
|
|
626
739
|
};
|
|
627
740
|
|
|
@@ -688,9 +801,10 @@
|
|
|
688
801
|
context,
|
|
689
802
|
fixer,
|
|
690
803
|
functions,
|
|
691
|
-
importPattern
|
|
804
|
+
importPattern,
|
|
805
|
+
node
|
|
692
806
|
}) => {
|
|
693
|
-
const root = context.getAncestors()[0];
|
|
807
|
+
const root = context.sourceCode.getAncestors(node)[0];
|
|
694
808
|
const packageImport = root.body.find(neetoCist.matches(importPattern));
|
|
695
809
|
if (packageImport) {
|
|
696
810
|
const extraImports = functions.filter(func => !packageImport.specifiers.some(ramda.pathEq(func, ["imported", "name"])));
|
|
@@ -712,11 +826,12 @@
|
|
|
712
826
|
context,
|
|
713
827
|
fixer,
|
|
714
828
|
functions: Array.isArray(functions) ? functions : [functions],
|
|
715
|
-
importPattern
|
|
829
|
+
importPattern,
|
|
830
|
+
node
|
|
716
831
|
});
|
|
717
832
|
if (imports) yield imports;
|
|
718
833
|
if (importNullSafe) {
|
|
719
|
-
const nullSafeImport = addNullSafeImport(context, fixer);
|
|
834
|
+
const nullSafeImport = addNullSafeImport(context, fixer, node);
|
|
720
835
|
if (nullSafeImport) yield nullSafeImport;
|
|
721
836
|
}
|
|
722
837
|
yield fixer.replaceText(node, fix);
|
|
@@ -1058,7 +1173,7 @@
|
|
|
1058
1173
|
}) => value.cooked.includes("?"))
|
|
1059
1174
|
};
|
|
1060
1175
|
|
|
1061
|
-
const isRoutesImportPresent = context => context.getAncestors()[0].body.some(neetoCist.matches(ROUTES_IMPORT_PATTERN));
|
|
1176
|
+
const isRoutesImportPresent = (context, node) => context.sourceCode.getAncestors(node)[0].body.some(neetoCist.matches(ROUTES_IMPORT_PATTERN));
|
|
1062
1177
|
var noRoutesDestructureAndReassignment = {
|
|
1063
1178
|
meta: {
|
|
1064
1179
|
type: "problem",
|
|
@@ -1069,17 +1184,17 @@
|
|
|
1069
1184
|
},
|
|
1070
1185
|
create: context => ({
|
|
1071
1186
|
VariableDeclaration(node) {
|
|
1072
|
-
if (neetoCist.matches(DECALARATION_PATTERN$1, node) && isRoutesImportPresent(context)) {
|
|
1187
|
+
if (neetoCist.matches(DECALARATION_PATTERN$1, node) && isRoutesImportPresent(context, node)) {
|
|
1073
1188
|
context.report(node, ROUTES_HAS_ALREADY_BEEN_DECLARED);
|
|
1074
1189
|
}
|
|
1075
1190
|
},
|
|
1076
1191
|
VariableDeclarator(node) {
|
|
1077
|
-
if (neetoCist.matches(ASSIGNMENT_PATTERN, node) && isRoutesImportPresent(context)) {
|
|
1192
|
+
if (neetoCist.matches(ASSIGNMENT_PATTERN, node) && isRoutesImportPresent(context, node)) {
|
|
1078
1193
|
context.report(node, NO_ROUTES_ASSIGNMENT);
|
|
1079
1194
|
}
|
|
1080
1195
|
},
|
|
1081
1196
|
AssignmentExpression(node) {
|
|
1082
|
-
if (neetoCist.matches(REASSIGNMENT_PATTERN, node) && isRoutesImportPresent(context)) {
|
|
1197
|
+
if (neetoCist.matches(REASSIGNMENT_PATTERN, node) && isRoutesImportPresent(context, node)) {
|
|
1083
1198
|
context.report(node, NO_ROUTES_REASSIGNMENT);
|
|
1084
1199
|
}
|
|
1085
1200
|
}
|
|
@@ -4689,14 +4804,12 @@
|
|
|
4689
4804
|
const findMatchedConfig = (context, configs) => {
|
|
4690
4805
|
const fullFilePath = context.getFilename();
|
|
4691
4806
|
const basePath = context.options[0].basePath;
|
|
4692
|
-
|
|
4807
|
+
return configs.find(config => {
|
|
4693
4808
|
const isIncluded = asArray(config.includes).some(pathPattern => minimatch$1(fullFilePath, basePath + pathPattern));
|
|
4694
4809
|
if (config.includes && !isIncluded) return false;
|
|
4695
4810
|
const isExcluded = asArray(config.excludes).some(pathPattern => minimatch$1(fullFilePath, basePath + pathPattern));
|
|
4696
|
-
|
|
4697
|
-
return true;
|
|
4811
|
+
return !(config.excludes && isExcluded);
|
|
4698
4812
|
});
|
|
4699
|
-
return matchedConfig;
|
|
4700
4813
|
};
|
|
4701
4814
|
const checkFilenameCase = (context, node, filenameCase) => {
|
|
4702
4815
|
const [filename] = getFilenameAndExtension(context);
|
|
@@ -4817,6 +4930,51 @@
|
|
|
4817
4930
|
docs: {
|
|
4818
4931
|
url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/file-name-and-export-name-standards.md",
|
|
4819
4932
|
description: "Allows you to enforce a consistent naming pattern for the filenames and exports."
|
|
4933
|
+
},
|
|
4934
|
+
schema: {
|
|
4935
|
+
type: "array",
|
|
4936
|
+
items: [{
|
|
4937
|
+
type: "object",
|
|
4938
|
+
properties: {
|
|
4939
|
+
basePath: {
|
|
4940
|
+
type: "string"
|
|
4941
|
+
},
|
|
4942
|
+
default: {
|
|
4943
|
+
type: "object",
|
|
4944
|
+
properties: {
|
|
4945
|
+
filenameCase: {
|
|
4946
|
+
type: "string"
|
|
4947
|
+
},
|
|
4948
|
+
exportnameCase: {
|
|
4949
|
+
type: "string"
|
|
4950
|
+
}
|
|
4951
|
+
}
|
|
4952
|
+
},
|
|
4953
|
+
configs: {
|
|
4954
|
+
type: "array",
|
|
4955
|
+
items: [{
|
|
4956
|
+
filenameCase: {
|
|
4957
|
+
type: "string"
|
|
4958
|
+
},
|
|
4959
|
+
exportnameCase: {
|
|
4960
|
+
type: "string"
|
|
4961
|
+
},
|
|
4962
|
+
includes: {
|
|
4963
|
+
type: ["string", "array"],
|
|
4964
|
+
items: [{
|
|
4965
|
+
type: "string"
|
|
4966
|
+
}]
|
|
4967
|
+
},
|
|
4968
|
+
excludes: {
|
|
4969
|
+
type: ["string", "array"],
|
|
4970
|
+
items: [{
|
|
4971
|
+
type: "string"
|
|
4972
|
+
}]
|
|
4973
|
+
}
|
|
4974
|
+
}]
|
|
4975
|
+
}
|
|
4976
|
+
}
|
|
4977
|
+
}]
|
|
4820
4978
|
}
|
|
4821
4979
|
},
|
|
4822
4980
|
create: context => ({
|
|
@@ -5243,7 +5401,7 @@
|
|
|
5243
5401
|
}
|
|
5244
5402
|
const isJSXTextType = node.type === TYPES.JSX_TEXT;
|
|
5245
5403
|
if (isJSXTextType) return true;
|
|
5246
|
-
const ancestors = context.getAncestors(node);
|
|
5404
|
+
const ancestors = context.sourceCode.getAncestors(node);
|
|
5247
5405
|
const isMatchesNaturalLangRegex = NATURAL_LANGUAGE_REGEX.test(nodeValue);
|
|
5248
5406
|
for (let i = ancestors.length - 1; i > 0; i--) {
|
|
5249
5407
|
const parent = ancestors[i];
|
|
@@ -5446,6 +5604,29 @@
|
|
|
5446
5604
|
docs: {
|
|
5447
5605
|
url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/no-missing-localization.md",
|
|
5448
5606
|
description: "Detects localization keys that do not have an associated value in the translations."
|
|
5607
|
+
},
|
|
5608
|
+
schema: {
|
|
5609
|
+
type: "array",
|
|
5610
|
+
items: [{
|
|
5611
|
+
type: "object",
|
|
5612
|
+
properties: {
|
|
5613
|
+
translationsDir: {
|
|
5614
|
+
type: "string"
|
|
5615
|
+
},
|
|
5616
|
+
languages: {
|
|
5617
|
+
type: "array",
|
|
5618
|
+
items: [{
|
|
5619
|
+
type: "string"
|
|
5620
|
+
}]
|
|
5621
|
+
},
|
|
5622
|
+
nanosTranslationDir: {
|
|
5623
|
+
type: "array",
|
|
5624
|
+
items: [{
|
|
5625
|
+
type: "string"
|
|
5626
|
+
}]
|
|
5627
|
+
}
|
|
5628
|
+
}
|
|
5629
|
+
}]
|
|
5449
5630
|
}
|
|
5450
5631
|
},
|
|
5451
5632
|
create: context => {
|
|
@@ -6538,7 +6719,8 @@
|
|
|
6538
6719
|
const reportSuggestion$1 = ({
|
|
6539
6720
|
context,
|
|
6540
6721
|
historyMethodCall,
|
|
6541
|
-
computeFix
|
|
6722
|
+
computeFix,
|
|
6723
|
+
node
|
|
6542
6724
|
}) => context.report({
|
|
6543
6725
|
node: historyMethodCall,
|
|
6544
6726
|
message: CAN_BE_REPLACED_WITH_HANDLE_META_CLICK,
|
|
@@ -6554,7 +6736,8 @@
|
|
|
6554
6736
|
context,
|
|
6555
6737
|
fixer,
|
|
6556
6738
|
functions: ["handleMetaClick"],
|
|
6557
|
-
importPattern: REACT_UTILS_IMPORT_PATTERN$2
|
|
6739
|
+
importPattern: REACT_UTILS_IMPORT_PATTERN$2,
|
|
6740
|
+
node
|
|
6558
6741
|
});
|
|
6559
6742
|
if (importStatement) fixerArray.push(importStatement);
|
|
6560
6743
|
return fixerArray;
|
|
@@ -6586,6 +6769,7 @@
|
|
|
6586
6769
|
reportSuggestion$1({
|
|
6587
6770
|
context,
|
|
6588
6771
|
historyMethodCall,
|
|
6772
|
+
node,
|
|
6589
6773
|
computeFix: ({
|
|
6590
6774
|
fixerArray,
|
|
6591
6775
|
fixer
|
|
@@ -6857,6 +7041,17 @@
|
|
|
6857
7041
|
docs: {
|
|
6858
7042
|
url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/no-axios-import-outside-apis.md",
|
|
6859
7043
|
description: `Axios should only be imported and used inside scripts within the "apis" directory`
|
|
7044
|
+
},
|
|
7045
|
+
schema: {
|
|
7046
|
+
type: "array",
|
|
7047
|
+
items: [{
|
|
7048
|
+
type: "object",
|
|
7049
|
+
patternProperties: {
|
|
7050
|
+
".*": {
|
|
7051
|
+
type: "string"
|
|
7052
|
+
}
|
|
7053
|
+
}
|
|
7054
|
+
}]
|
|
6860
7055
|
}
|
|
6861
7056
|
},
|
|
6862
7057
|
create: context => ({
|
|
@@ -7107,7 +7302,8 @@
|
|
|
7107
7302
|
context,
|
|
7108
7303
|
fixer,
|
|
7109
7304
|
functions: ["withT"],
|
|
7110
|
-
importPattern: NEETO_COMMONS_REACT_UTILS_IMPORT_PATTERN
|
|
7305
|
+
importPattern: NEETO_COMMONS_REACT_UTILS_IMPORT_PATTERN,
|
|
7306
|
+
node
|
|
7111
7307
|
});
|
|
7112
7308
|
importWithT && fixers.push(importWithT);
|
|
7113
7309
|
return fixers;
|
|
@@ -7174,6 +7370,17 @@
|
|
|
7174
7370
|
docs: {
|
|
7175
7371
|
url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/no-large-functions-inside-jsx.md",
|
|
7176
7372
|
description: "Disallows the use of functions with large bodies, that exceed maxAllowedNoOfLines, directly inside JSX elements." + "The default value for maxAllowedNoOfLines is 4."
|
|
7373
|
+
},
|
|
7374
|
+
schema: {
|
|
7375
|
+
type: "array",
|
|
7376
|
+
items: [{
|
|
7377
|
+
type: "object",
|
|
7378
|
+
properties: {
|
|
7379
|
+
maxAllowedNoOfLines: {
|
|
7380
|
+
type: "number"
|
|
7381
|
+
}
|
|
7382
|
+
}
|
|
7383
|
+
}]
|
|
7177
7384
|
}
|
|
7178
7385
|
},
|
|
7179
7386
|
create: context => ({
|
|
@@ -7294,6 +7501,17 @@
|
|
|
7294
7501
|
docs: {
|
|
7295
7502
|
url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/no-multiple-components-in-a-file.md",
|
|
7296
7503
|
description: "Do not have multiple component definitions that exceed maxAllowedNoOfLines in a single file." + "The default value for maxAllowedNoOfLines is 20."
|
|
7504
|
+
},
|
|
7505
|
+
schema: {
|
|
7506
|
+
type: "array",
|
|
7507
|
+
items: [{
|
|
7508
|
+
type: "object",
|
|
7509
|
+
properties: {
|
|
7510
|
+
maxAllowedNoOfLines: {
|
|
7511
|
+
type: "number"
|
|
7512
|
+
}
|
|
7513
|
+
}
|
|
7514
|
+
}]
|
|
7297
7515
|
}
|
|
7298
7516
|
},
|
|
7299
7517
|
create: context => ({
|
|
@@ -7775,14 +7993,14 @@
|
|
|
7775
7993
|
const codeInsideBody = getCode$1(context, arrowFunctionExpression.body);
|
|
7776
7994
|
const codeWithUseTranslation = insertTextAfterPosition(0, codeInsideBody, "const { t } = useTranslation();\n");
|
|
7777
7995
|
const updatedProps = getPropsCode(context, arrowFunctionExpression, props);
|
|
7778
|
-
|
|
7779
|
-
return replacedCodeWithUseTranslation;
|
|
7996
|
+
return `(${updatedProps}${ramda.isEmpty(restParams) ? "" : `${neetoCist.isNotEmpty(updatedProps) ? ", " : "{}, "}${restParams.map(param => getCode$1(context, param)).join(", ")}`}) => ${codeWithUseTranslation}`;
|
|
7780
7997
|
};
|
|
7781
|
-
const createUseTranslationImport = (context, fixer) => addFunctionImport({
|
|
7998
|
+
const createUseTranslationImport = (context, fixer, node) => addFunctionImport({
|
|
7782
7999
|
context,
|
|
7783
8000
|
fixer,
|
|
7784
8001
|
functions: ["useTranslation"],
|
|
7785
|
-
importPattern: REACT_I18_IMPORT_PATTERN
|
|
8002
|
+
importPattern: REACT_I18_IMPORT_PATTERN,
|
|
8003
|
+
node
|
|
7786
8004
|
});
|
|
7787
8005
|
const insertTextAfterPosition = (position, inputString, textToInsert) => {
|
|
7788
8006
|
const firstCharacter = inputString.charAt(position);
|
|
@@ -7806,7 +8024,7 @@
|
|
|
7806
8024
|
} else {
|
|
7807
8025
|
fixers.push(fixer.replaceText(node.declarations[0].init, replacedCodeWithUseTranslation));
|
|
7808
8026
|
}
|
|
7809
|
-
const importUseTranslation = createUseTranslationImport(context, fixer);
|
|
8027
|
+
const importUseTranslation = createUseTranslationImport(context, fixer, node);
|
|
7810
8028
|
importUseTranslation && fixers.push(importUseTranslation);
|
|
7811
8029
|
return fixers;
|
|
7812
8030
|
}
|
|
@@ -7895,17 +8113,16 @@
|
|
|
7895
8113
|
type: "problem",
|
|
7896
8114
|
docs: {
|
|
7897
8115
|
url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/prefix-neeto-ui-import-alias.md",
|
|
7898
|
-
description: PREFIX_NEETO_UI_IMPORT_ALIAS_MESSAGE
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
}
|
|
8116
|
+
description: PREFIX_NEETO_UI_IMPORT_ALIAS_MESSAGE
|
|
8117
|
+
},
|
|
8118
|
+
schema: [{
|
|
8119
|
+
type: "object",
|
|
8120
|
+
patternProperties: {
|
|
8121
|
+
".*": {
|
|
8122
|
+
type: "string"
|
|
7906
8123
|
}
|
|
7907
8124
|
}
|
|
7908
|
-
}
|
|
8125
|
+
}]
|
|
7909
8126
|
},
|
|
7910
8127
|
create: context => ({
|
|
7911
8128
|
ImportSpecifier(node) {
|
|
@@ -8303,8 +8520,8 @@
|
|
|
8303
8520
|
fix: fixer => {
|
|
8304
8521
|
let fixToRemoveComma = null;
|
|
8305
8522
|
let fixToRemoveErrorNode = fixer.remove(property);
|
|
8306
|
-
const tokenBefore = context.getTokenBefore(property);
|
|
8307
|
-
const tokenAfter = context.getTokenAfter(property);
|
|
8523
|
+
const tokenBefore = context.sourceCode.getTokenBefore(property);
|
|
8524
|
+
const tokenAfter = context.sourceCode.getTokenAfter(property);
|
|
8308
8525
|
if (tokenAfter.value === ",") {
|
|
8309
8526
|
fixToRemoveComma = fixer.remove(tokenAfter);
|
|
8310
8527
|
} else if (tokenBefore.value === ",") {
|
|
@@ -9489,7 +9706,7 @@
|
|
|
9489
9706
|
const fixerArray = [fixer.replaceText(expressionNode, fixString)];
|
|
9490
9707
|
const importExists = neetoCist.existsBy(CLASSNAMES_IMPORT_PATTERN, getAllImports(node));
|
|
9491
9708
|
if (!importExists) {
|
|
9492
|
-
const addImport = fixer.insertTextBefore(context.getAncestors()[0], 'import classnames from "classnames";\n');
|
|
9709
|
+
const addImport = fixer.insertTextBefore(context.sourceCode.getAncestors(node)[0], 'import classnames from "classnames";\n');
|
|
9493
9710
|
fixerArray.push(addImport);
|
|
9494
9711
|
}
|
|
9495
9712
|
return fixerArray;
|
|
@@ -9740,7 +9957,8 @@
|
|
|
9740
9957
|
context,
|
|
9741
9958
|
fixer,
|
|
9742
9959
|
functions: ["createSubscription"],
|
|
9743
|
-
importPattern: NEETO_COMMONS_UTILS_IMPORT_PATTERN
|
|
9960
|
+
importPattern: NEETO_COMMONS_UTILS_IMPORT_PATTERN,
|
|
9961
|
+
node
|
|
9744
9962
|
});
|
|
9745
9963
|
if (addedImport) fixerArray.push(addedImport);
|
|
9746
9964
|
return fixerArray;
|
|
@@ -10247,7 +10465,8 @@
|
|
|
10247
10465
|
context,
|
|
10248
10466
|
fixer,
|
|
10249
10467
|
functions: ["showThumbsUpToastr"],
|
|
10250
|
-
importPattern: NEETO_COMMONS_UTILS_IMPORT_PATTERN
|
|
10468
|
+
importPattern: NEETO_COMMONS_UTILS_IMPORT_PATTERN,
|
|
10469
|
+
node
|
|
10251
10470
|
});
|
|
10252
10471
|
if (addImport) fixerArr.push(addImport);
|
|
10253
10472
|
return fixerArr;
|
|
@@ -10487,14 +10706,15 @@
|
|
|
10487
10706
|
context,
|
|
10488
10707
|
fixer,
|
|
10489
10708
|
functions: ["useMutationWithInvalidation"],
|
|
10490
|
-
importPattern: REACT_UTILS_IMPORT_PATTERN$1
|
|
10709
|
+
importPattern: REACT_UTILS_IMPORT_PATTERN$1,
|
|
10710
|
+
node
|
|
10491
10711
|
});
|
|
10492
10712
|
fixerArray.push(addImport);
|
|
10493
10713
|
}
|
|
10494
10714
|
return fixerArray;
|
|
10495
10715
|
};
|
|
10496
10716
|
const getRemoveCommaFix = (context, fixer, onSuccess) => {
|
|
10497
|
-
const tokenAfter = context.getTokenAfter(onSuccess);
|
|
10717
|
+
const tokenAfter = context.sourceCode.getTokenAfter(onSuccess);
|
|
10498
10718
|
return tokenAfter.value === "," ? fixer.remove(tokenAfter) : null;
|
|
10499
10719
|
};
|
|
10500
10720
|
const getVariables = (context, params) => {
|
|
@@ -10692,7 +10912,8 @@
|
|
|
10692
10912
|
context,
|
|
10693
10913
|
fixer,
|
|
10694
10914
|
functions: ["useQueryClient"],
|
|
10695
|
-
importPattern: REACT_QUERY_IMPORT_PATTERN
|
|
10915
|
+
importPattern: REACT_QUERY_IMPORT_PATTERN,
|
|
10916
|
+
node
|
|
10696
10917
|
});
|
|
10697
10918
|
return [initializeQueryClient, addImport];
|
|
10698
10919
|
}
|
|
@@ -10712,14 +10933,14 @@
|
|
|
10712
10933
|
description: "Shows import paths that can be simplified using aliases configured by webpack.",
|
|
10713
10934
|
schema: {
|
|
10714
10935
|
type: "object",
|
|
10715
|
-
description: "An object mapping aliases to paths.",
|
|
10716
10936
|
patternProperties: {
|
|
10717
|
-
"
|
|
10937
|
+
".*": {
|
|
10718
10938
|
type: "string"
|
|
10719
10939
|
}
|
|
10720
10940
|
}
|
|
10721
10941
|
}
|
|
10722
|
-
}
|
|
10942
|
+
},
|
|
10943
|
+
schema: false
|
|
10723
10944
|
},
|
|
10724
10945
|
create: context => ({
|
|
10725
10946
|
ImportDeclaration(node) {
|
|
@@ -10752,6 +10973,21 @@
|
|
|
10752
10973
|
docs: {
|
|
10753
10974
|
url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/webpack-aliases-and-jsconfig-paths-should-be-in-sync.md",
|
|
10754
10975
|
description: "Ensures that webpack alias and jsconfig are in sync"
|
|
10976
|
+
},
|
|
10977
|
+
schema: {
|
|
10978
|
+
type: "array",
|
|
10979
|
+
items: [{
|
|
10980
|
+
type: "object",
|
|
10981
|
+
properties: {
|
|
10982
|
+
jsconfigFilePath: {
|
|
10983
|
+
type: "string"
|
|
10984
|
+
},
|
|
10985
|
+
aliasFilePath: {
|
|
10986
|
+
type: "string"
|
|
10987
|
+
}
|
|
10988
|
+
},
|
|
10989
|
+
additionalProperties: false
|
|
10990
|
+
}]
|
|
10755
10991
|
}
|
|
10756
10992
|
},
|
|
10757
10993
|
create: context => {
|
|
@@ -11101,10 +11337,9 @@
|
|
|
11101
11337
|
})
|
|
11102
11338
|
};
|
|
11103
11339
|
|
|
11104
|
-
const isImportedFromReact = context => {
|
|
11105
|
-
const root = context.getAncestors()[0];
|
|
11106
|
-
|
|
11107
|
-
return isImportExist;
|
|
11340
|
+
const isImportedFromReact = (context, node) => {
|
|
11341
|
+
const root = context.sourceCode.getAncestors(node)[0];
|
|
11342
|
+
return root.body.some(neetoCist.matches(CREATE_CONTEXT_IMPORT_PATTERN));
|
|
11108
11343
|
};
|
|
11109
11344
|
var useZustandForGlobalStateManagement = {
|
|
11110
11345
|
meta: {
|
|
@@ -11116,7 +11351,7 @@
|
|
|
11116
11351
|
},
|
|
11117
11352
|
create: context => ({
|
|
11118
11353
|
CallExpression(node) {
|
|
11119
|
-
if (neetoCist.matches(REACT_CREATE_CONTEXT_PATTERN, node) || neetoCist.matches(CREATE_CONTEXT_PATTERN, node) && isImportedFromReact(context)) {
|
|
11354
|
+
if (neetoCist.matches(REACT_CREATE_CONTEXT_PATTERN, node) || neetoCist.matches(CREATE_CONTEXT_PATTERN, node) && isImportedFromReact(context, node)) {
|
|
11120
11355
|
context.report({
|
|
11121
11356
|
node,
|
|
11122
11357
|
message: USE_ZUSTAND_FOR_GLOBAL_STATE_MANAGEMENT
|
|
@@ -11227,7 +11462,8 @@
|
|
|
11227
11462
|
context,
|
|
11228
11463
|
fixer,
|
|
11229
11464
|
functions: ["withImmutableActions"],
|
|
11230
|
-
importPattern: REACT_UTILS_IMPORT_PATTERN
|
|
11465
|
+
importPattern: REACT_UTILS_IMPORT_PATTERN,
|
|
11466
|
+
node
|
|
11231
11467
|
});
|
|
11232
11468
|
if (addImportFixer) fixerArray.push(addImportFixer);
|
|
11233
11469
|
return fixerArray;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/eslint-plugin-neeto",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"scripts": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@bigbinary/babel-preset-neeto": "^1.0.3",
|
|
39
39
|
"@bigbinary/eslint-plugin-neeto": "1.5.5",
|
|
40
40
|
"@bigbinary/neeto-cist": "^1.0.3",
|
|
41
|
-
"@bigbinary/neeto-commons-frontend": "4.
|
|
41
|
+
"@bigbinary/neeto-commons-frontend": "^4.13.35",
|
|
42
42
|
"@rollup/plugin-alias": "^3.1.9",
|
|
43
43
|
"@rollup/plugin-babel": "^6.0.4",
|
|
44
44
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
@@ -57,20 +57,20 @@
|
|
|
57
57
|
"babel-preset-typescript": "^7.0.0-alpha.19",
|
|
58
58
|
"cheerio": "^1.0.0-rc.12",
|
|
59
59
|
"command-line-args": "^5.2.1",
|
|
60
|
-
"eslint": "
|
|
61
|
-
"eslint-config-prettier": "
|
|
62
|
-
"eslint-plugin-cypress": "
|
|
63
|
-
"eslint-plugin-import": "2.
|
|
64
|
-
"eslint-plugin-jam3": "0.2.3",
|
|
65
|
-
"eslint-plugin-json": "
|
|
66
|
-
"eslint-plugin-prettier": "
|
|
67
|
-
"eslint-plugin-promise": "
|
|
68
|
-
"eslint-plugin-react": "7.
|
|
69
|
-
"eslint-plugin-react-hooks": "
|
|
70
|
-
"eslint-plugin-security": "^
|
|
71
|
-
"eslint-plugin-sonarjs": "^0.
|
|
72
|
-
"eslint-plugin-unused-imports": "
|
|
73
|
-
"
|
|
60
|
+
"eslint": "^9.25.1",
|
|
61
|
+
"eslint-config-prettier": "^10.1.2",
|
|
62
|
+
"eslint-plugin-cypress": "^4.3.0",
|
|
63
|
+
"eslint-plugin-import": "^2.31.0",
|
|
64
|
+
"eslint-plugin-jam3": "^0.2.3",
|
|
65
|
+
"eslint-plugin-json": "^4.0.1",
|
|
66
|
+
"eslint-plugin-prettier": "^5.2.6",
|
|
67
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
68
|
+
"eslint-plugin-react": "^7.37.5",
|
|
69
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
70
|
+
"eslint-plugin-security": "^3.0.1",
|
|
71
|
+
"eslint-plugin-sonarjs": "^3.0.2",
|
|
72
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
73
|
+
"globals": "^16.0.0",
|
|
74
74
|
"husky": "7.0.4",
|
|
75
75
|
"i18next": "21.7.0",
|
|
76
76
|
"jest": "27.5.1",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"peerDependencies": {
|
|
90
90
|
"@bigbinary/neeto-cist": "^1.0.3",
|
|
91
91
|
"@bigbinary/neeto-commons-frontend": "4.12.3",
|
|
92
|
-
"eslint": "
|
|
92
|
+
"eslint": "^9.25.1",
|
|
93
93
|
"i18next": "21.7.0",
|
|
94
94
|
"ramda": "0.29.0"
|
|
95
95
|
}
|