@bigbinary/eslint-plugin-neeto 1.8.3 → 1.8.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 +40 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,6 +75,7 @@ of the issues identified in JavaScript code.
|
|
|
75
75
|
- [no-buildurl-call-with-empty-params](./docs/src/rules/no-buildurl-call-with-empty-params.md)
|
|
76
76
|
- [no-conditional-overlays](./docs/src/rules/no-conditional-overlays.md)
|
|
77
77
|
- [no-deprecated-imports-from-zustand](./docs/src/rules/no-deprecated-imports-from-zustand.md)
|
|
78
|
+
- [no-edits-to-generated-translation-files](./docs/src/rules/no-edits-to-generated-translation-files.md)
|
|
78
79
|
- [no-dangling-constants](./docs/src/rules/no-dangling-constants.md)
|
|
79
80
|
- [no-globalProps-destructure](./docs/src/rules/no-globalProps-destructure.md)
|
|
80
81
|
- [no-globalProps-reassignment](./docs/src/rules/no-globalProps-reassignment.md)
|
package/dist/index.js
CHANGED
|
@@ -109,6 +109,7 @@
|
|
|
109
109
|
"@bigbinary/neeto/no-buildurl-call-with-empty-params": "error",
|
|
110
110
|
"@bigbinary/neeto/no-conditional-overlays": "error",
|
|
111
111
|
"@bigbinary/neeto/no-deprecated-imports-from-zustand": "error",
|
|
112
|
+
"@bigbinary/neeto/no-edits-to-generated-translation-files": "error",
|
|
112
113
|
"@bigbinary/neeto/no-dangling-constants": "error",
|
|
113
114
|
"@bigbinary/neeto/no-excess-function-arguments": "warn",
|
|
114
115
|
"@bigbinary/neeto/no-globalProps-destructure": "error",
|
|
@@ -138,7 +139,6 @@
|
|
|
138
139
|
"@bigbinary/neeto/use-i18next-plurals": "error",
|
|
139
140
|
"@bigbinary/neeto/use-inline-svg-for-render": "error",
|
|
140
141
|
"@bigbinary/neeto/use-title-case-neeto-in-strings": "warn",
|
|
141
|
-
"@bigbinary/neeto/use-neetoui-classes": "warn",
|
|
142
142
|
"@bigbinary/neeto/use-permissions-prop-in-private-route": "warn",
|
|
143
143
|
"@bigbinary/neeto/use-pluralize-package": "error",
|
|
144
144
|
"@bigbinary/neeto/use-react-query-for-managing-remote-data": "warn",
|
|
@@ -280,12 +280,11 @@
|
|
|
280
280
|
"@bigbinary/neeto/use-react-query-for-managing-remote-data": "off",
|
|
281
281
|
"@bigbinary/neeto/use-webpack-alias": ["error", resolve.alias],
|
|
282
282
|
"@bigbinary/neeto/webpack-aliases-and-jsconfig-paths-should-be-in-sync": "off",
|
|
283
|
-
"@bigbinary/neeto/use-neetoui-classes": "off",
|
|
284
283
|
"@bigbinary/neeto/hard-coded-strings-should-be-localized": "off"
|
|
285
284
|
}
|
|
286
285
|
});
|
|
287
286
|
|
|
288
|
-
var version = "1.8.
|
|
287
|
+
var version = "1.8.4";
|
|
289
288
|
var packageJson = {
|
|
290
289
|
version: version};
|
|
291
290
|
|
|
@@ -315,6 +314,8 @@
|
|
|
315
314
|
const REACT_QUERY_DIRECTORY = "app/javascript/src/hooks/reactQuery";
|
|
316
315
|
const ROUTES_FILE_PATH = "app/javascript/src/routes.js";
|
|
317
316
|
const COMPONENTS_DIRECTORY = "app/javascript/src/components";
|
|
317
|
+
const TRANSLATIONS_DIRECTORY = "app/javascript/src/translations";
|
|
318
|
+
const TRANSLATION_SOURCE_LOCALE = "en";
|
|
318
319
|
const BLACKLISTED_PACKAGES = ["moment", "bootstrap", "blueprint", "react-spinners", "react-table", "remixicon", "mjml", "react-select", "@bigbinary/neeto-utils"];
|
|
319
320
|
const TYPES = {
|
|
320
321
|
ARRAY_EXPRESSION: "ArrayExpression",
|
|
@@ -545,6 +546,7 @@
|
|
|
545
546
|
const HELP_URL_INCORRECT_FORMAT = "Incorrect help URL format. Please use the 'help.neeto<product>.com' format instead of 'neeto<product>help.neetokb.com'.";
|
|
546
547
|
const INVALID_SWITCH_CHILD_MESSAGE = "Switch component can only contain Route, Redirect, or PrivateRoute as direct children";
|
|
547
548
|
const PREFER_RADIO_BUTTONS_FOR_FEW_OPTIONS = "Consider using Radio buttons instead of Dropdown/Select when there are fewer than 4 options.";
|
|
549
|
+
const NO_EDITS_TO_GENERATED_TRANSLATION_FILES = "This translation file is auto-generated. Only edit 'en.json'; translations for all other locales are generated from it automatically. Please revert your changes in this file.";
|
|
548
550
|
|
|
549
551
|
const PACKAGES_TO_CHECK = ["@bigbinary/neeto-molecules", "@bigbinary/neetoui", "@bigbinary/neeto-commons-frontend"];
|
|
550
552
|
|
|
@@ -716,6 +718,19 @@
|
|
|
716
718
|
return filename.startsWith(componentsDirectory);
|
|
717
719
|
};
|
|
718
720
|
|
|
721
|
+
/**
|
|
722
|
+
* Checks if the file is an auto-generated translation file, i.e. a JSON locale
|
|
723
|
+
* file inside the `translations` directory other than the source locale
|
|
724
|
+
* (en.json), which is the only file meant to be edited by hand.
|
|
725
|
+
* @param {Object} context eslint context
|
|
726
|
+
* @returns true if the file is a generated (non-source) translation file
|
|
727
|
+
*/
|
|
728
|
+
const isGeneratedTranslationFile = context => {
|
|
729
|
+
const [filename, extension] = getFilenameAndExtension(context);
|
|
730
|
+
const translationsDirectory = path$1.resolve(TRANSLATIONS_DIRECTORY);
|
|
731
|
+
return context.getFilename().startsWith(translationsDirectory) && extension === "json" && filename !== TRANSLATION_SOURCE_LOCALE;
|
|
732
|
+
};
|
|
733
|
+
|
|
719
734
|
/**
|
|
720
735
|
* Checks if the specified package is imported or not
|
|
721
736
|
* using the package name or any alias
|
|
@@ -789,8 +804,7 @@
|
|
|
789
804
|
const parseJsonData = filePath => {
|
|
790
805
|
try {
|
|
791
806
|
const jsonData = fs.readFileSync(filePath).toString();
|
|
792
|
-
|
|
793
|
-
return parsedJsonData;
|
|
807
|
+
return JSON.parse(removeComments(jsonData));
|
|
794
808
|
} catch {
|
|
795
809
|
return {};
|
|
796
810
|
}
|
|
@@ -7518,6 +7532,26 @@
|
|
|
7518
7532
|
})
|
|
7519
7533
|
};
|
|
7520
7534
|
|
|
7535
|
+
var noEditsToGeneratedTranslationFiles = {
|
|
7536
|
+
meta: {
|
|
7537
|
+
type: "problem",
|
|
7538
|
+
docs: {
|
|
7539
|
+
url: "https://github.com/neetozone/eslint-plugin-neeto/blob/main/docs/src/rules/no-edits-to-generated-translation-files.md",
|
|
7540
|
+
description: "Disallows manual edits to auto-generated translation files. Only the source locale (en.json) should be edited by hand."
|
|
7541
|
+
}
|
|
7542
|
+
},
|
|
7543
|
+
create: context => ({
|
|
7544
|
+
Program(node) {
|
|
7545
|
+
if (isGeneratedTranslationFile(context)) {
|
|
7546
|
+
context.report({
|
|
7547
|
+
node,
|
|
7548
|
+
message: NO_EDITS_TO_GENERATED_TRANSLATION_FILES
|
|
7549
|
+
});
|
|
7550
|
+
}
|
|
7551
|
+
}
|
|
7552
|
+
})
|
|
7553
|
+
};
|
|
7554
|
+
|
|
7521
7555
|
const nonDefaultParam = ({
|
|
7522
7556
|
type
|
|
7523
7557
|
}) => type !== TYPES.ASSIGNMENT_PATTERN;
|
|
@@ -12217,6 +12251,7 @@
|
|
|
12217
12251
|
"no-axios-import-outside-apis": noAxiosImportOutsideApis,
|
|
12218
12252
|
"no-conditional-overlays": noConditionalOverlays,
|
|
12219
12253
|
"no-deprecated-imports-from-zustand": noDeprecatedImportsFromZustand,
|
|
12254
|
+
"no-edits-to-generated-translation-files": noEditsToGeneratedTranslationFiles,
|
|
12220
12255
|
"no-excess-function-arguments": noExcessFunctionArguments,
|
|
12221
12256
|
"no-dangling-constants": noDanglingConstants,
|
|
12222
12257
|
"no-globalProps-destructure": noGlobalPropsDestructure,
|