@zohodesk/codestandard-validator 0.0.7-exp-4 → 0.0.7-exp-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.
Files changed (69) hide show
  1. package/build/hooks/Precommit/pre-commit.js +74 -24
  2. package/build/hooks/hook.js +29 -0
  3. package/build/utils/FileAndFolderOperations/filterFiles.js +27 -2
  4. package/build/utils/General/getGeneralInfo.js +7 -1
  5. package/build/utils/PluginsInstallation/installPlugins.js +1 -1
  6. package/configuration/.prettierignore +1 -0
  7. package/configuration/.prettierrc +13 -0
  8. package/configuration/common/.eslintrc.js +18 -0
  9. package/configuration/common/index.js +8 -0
  10. package/configuration/common/pluginVersion.js +3 -0
  11. package/configuration/services/Desk-Extension/.eslintrc.js +23 -0
  12. package/configuration/services/Desk-Extension/index.js +25 -0
  13. package/configuration/services/Desk-Extension/pluginVersion.js +16 -0
  14. package/configuration/services/Desk-Extension/rule_configuration/css_rules/cssRuleConfiguration.js +15 -0
  15. package/configuration/services/Desk-Extension/rule_configuration/i18nRules/noHardcodingRuleExcludes.js +41 -0
  16. package/configuration/services/Desk-Extension/rule_configuration/unUsed/unUsedImport.js +14 -0
  17. package/configuration/services/GC_Chat/index.js +21 -0
  18. package/configuration/services/GC_Chat/pluginVersion.js +12 -0
  19. package/configuration/services/GC_Chat/rule_configuration/i18nRules/i18nRules.js +284 -0
  20. package/configuration/services/GC_Chat/rule_configuration/react-performance-rules/reactPerformanceRulesConfig.js +26 -0
  21. package/configuration/services/client_platform/.eslintrc.js +35 -0
  22. package/configuration/services/client_platform/index.js +16 -0
  23. package/configuration/services/client_platform/pluginVersion.js +12 -0
  24. package/configuration/services/client_platform/rule_configuration/architecture_rules/architectureRuleConfiguration.js +172 -0
  25. package/configuration/services/client_platform/rule_configuration/architecture_rules/clientScriptRuleConfiguration.js +19 -0
  26. package/configuration/services/client_platform/rule_configuration/architecture_rules/customFieldRuleConfiguration.js +30 -0
  27. package/configuration/services/client_platform/rule_configuration/architecture_rules/errorHandlerRuleConfiguration.js +34 -0
  28. package/configuration/services/client_platform/rule_configuration/architecture_rules/layerConfiguration.js +52 -0
  29. package/configuration/services/client_platform/rule_configuration/i18n/i18n.js +39 -0
  30. package/configuration/services/client_platform/rule_configuration/sdk/sdk.js +23 -0
  31. package/configuration/services/desk_client_app/.eslintrc.js +23 -0
  32. package/configuration/services/desk_client_app/index.js +41 -0
  33. package/configuration/services/desk_client_app/pluginVersion.js +52 -0
  34. package/configuration/services/desk_client_app/rule_configuration/i18nRules/noHardcodingRuleExcludes.js +49 -0
  35. package/configuration/services/desk_client_app/rule_configuration/propertiesFileValidation/propertiesFileExcludes.js +23 -0
  36. package/configuration/services/desk_client_app/rule_configuration/react-compiler/reactCompilerConfig.js +25 -0
  37. package/configuration/services/desk_client_app/rule_configuration/react-general/reactGeneralConfig.js +33 -0
  38. package/configuration/services/desk_client_app/rule_configuration/react-performance-rules/reactPerformanceRulesConfig.js +84 -0
  39. package/configuration/services/desk_client_app/rule_configuration/uatRules/uatRules.js +23 -0
  40. package/configuration/services/desk_client_app/rule_configuration/unused-imports/unusedImportsConfig.js +28 -0
  41. package/configuration/services/helpcenter_product/.eslintrc.js +23 -0
  42. package/configuration/services/helpcenter_product/index.js +33 -0
  43. package/configuration/services/helpcenter_product/pluginVersion.js +33 -0
  44. package/configuration/services/helpcenter_product/rule_configuration/i18nRules/noHardcodingRuleExcludes.js +40 -0
  45. package/configuration/services/helpcenter_product/rule_configuration/react-compiler/reactCompilerConfig.js +18 -0
  46. package/configuration/services/helpcenter_product/rule_configuration/react-general/reactGeneralConfig.js +24 -0
  47. package/configuration/services/helpcenter_product/rule_configuration/react-performance-rules/reactPerformanceRulesConfig.js +25 -0
  48. package/configuration/services/zohodesk/.eslintrc.js +22 -0
  49. package/configuration/services/zohodesk/index.js +15 -0
  50. package/configuration/services/zohodesk/pluginVersion.js +7 -0
  51. package/configuration/services/zohodesk/rule_configuration/select2RestrictedOptions/select2Excludes.js +8 -0
  52. package/configuration/services/zohogc_client/.eslintrc.js +23 -0
  53. package/configuration/services/zohogc_client/index.js +22 -0
  54. package/configuration/services/zohogc_client/pluginVersion.js +27 -0
  55. package/configuration/services/zohogc_client/rule_configuration/fitnessFunction/fitnessFunctionRules.js +31 -0
  56. package/configuration/services/zohogc_client/rule_configuration/i18nRules/i18nRules.js +303 -0
  57. package/configuration/services/zohogc_client/rule_configuration/react-performance-rules/reactPerformanceRulesConfig.js +27 -0
  58. package/configuration/services/zohogc_client/rule_configuration/uatRules/uatRules.js +23 -0
  59. package/configuration/services/zohoim_client/.eslintrc.js +23 -0
  60. package/configuration/services/zohoim_client/defaultRule.txt +243 -0
  61. package/configuration/services/zohoim_client/index.js +28 -0
  62. package/configuration/services/zohoim_client/pluginVersion.js +38 -0
  63. package/configuration/services/zohoim_client/rule_configuration/i18nRules/noHardcodingRule.js +38 -0
  64. package/configuration/services/zohoim_client/rule_configuration/propertiesFileValidation/propertiesFileRule.js +23 -0
  65. package/configuration/services/zohoim_client/rule_configuration/react-compiler/reactCompilerConfig.js +16 -0
  66. package/configuration/services/zohoim_client/rule_configuration/react-general/reactGeneralConfig.js +22 -0
  67. package/configuration/services/zohoim_client/rule_configuration/react-performance-rules/reactPerformanceRulesConfig.js +19 -0
  68. package/configuration/services/zohoim_client/rule_configuration/uatRules/uatRules.js +21 -0
  69. package/package.json +1 -1
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  const {
4
- exec
4
+ exec,
5
+ execSync
5
6
  } = require('child_process');
6
7
  const fs = require('fs');
7
8
  const path = require('path');
@@ -87,6 +88,22 @@ function filterDeltedFileFromStagedFiles(files) {
87
88
  return false;
88
89
  });
89
90
  }
91
+ async function lintFiles(filePath) {
92
+ switch (path.extname(filePath)) {
93
+ case '.js' || '.ts' || '.tsx' || '.jsx':
94
+ {
95
+ return await findEslintErrors(filePath);
96
+ }
97
+ case '.css' || '.scss':
98
+ {
99
+ return await findStyleLintErrors(filePath);
100
+ }
101
+ default:
102
+ {
103
+ return [];
104
+ }
105
+ }
106
+ }
90
107
 
91
108
  /**
92
109
  * @function findEslintErrors - method Lint given file based on given configuration
@@ -94,7 +111,7 @@ function filterDeltedFileFromStagedFiles(files) {
94
111
  * @returns {Array<string>} - array of command line report as a string
95
112
  */
96
113
 
97
- async function findEslintErrors(file) {
114
+ function findEslintErrors(file) {
98
115
  let nodeModulesPathOfProject = `${getNodeModulesPath()}`;
99
116
  let eslintExecutablePath = getEslintExecutablePath();
100
117
  let eslintConfigurationFilePath = `${nodeModulesPathOfProject}/.eslintrc.js`;
@@ -121,6 +138,35 @@ async function findEslintErrors(file) {
121
138
  Logger.log(Logger.INFO_TYPE, 'node_modules not found');
122
139
  }
123
140
  }
141
+
142
+ /**
143
+ *
144
+ * @param {*} params
145
+ */
146
+ function findStyleLintErrors(filePath) {
147
+ const configFilePath = path.resolve(getNodeModulesPath(), '.stylelintrc.json');
148
+ const absolutePath = path.join(getRootDirectory(), filePath);
149
+ try {
150
+ return new Promise((resolve, reject) => {
151
+ exec(`npx stylelint ${absolutePath} --config ${configFilePath}`, {
152
+ cwd: getNodeModulesPath()
153
+ }, (error, stderr, stdout) => {
154
+ if (stderr) {
155
+ resolve(stderr.trim().split('\n'));
156
+ } else if (error) {
157
+ Logger.log(Logger.FAILURE_TYPE, error);
158
+ reject("Error executing eslint command");
159
+ } else {
160
+ resolve([]);
161
+ }
162
+ });
163
+ });
164
+ } catch (error) {
165
+ Logger.log(Logger.FAILURE_TYPE, `Issue is lint css files`);
166
+ return [];
167
+ }
168
+ }
169
+
124
170
  /**
125
171
  * @function {calculateGitDiffForFile} - method calculate diff of file
126
172
  * @param {*} branch_name - branch name
@@ -157,10 +203,10 @@ function isOnlyWarningsPresentInFile(eslintErrorsPresent) {
157
203
  let severityOfEachErrorInFile = [];
158
204
  eslintErrorsPresent.map(error => {
159
205
  let partsInString = error.split(" ");
160
- let severityOfError = partsInString.find(word => word === 'error' || word === 'warning');
206
+ let severityOfError = partsInString.find(word => word === 'error' || word === 'warning' || word === '✖');
161
207
  severityOfEachErrorInFile.push(severityOfError);
162
208
  });
163
- return !severityOfEachErrorInFile.includes('error');
209
+ return !(severityOfEachErrorInFile.includes('✖') || severityOfEachErrorInFile.includes('error'));
164
210
  }
165
211
 
166
212
  /**
@@ -193,29 +239,33 @@ async function preCommitHook() {
193
239
  try {
194
240
  staged_files = await getStagedFiles();
195
241
  if (!staged_files.length == 0) {
196
- staged_files = filterFiles(staged_files, eslintConfigFiles, true);
242
+ const {
243
+ JsFiles: staged_filesJS,
244
+ CssFiles
245
+ } = filterFiles(staged_files, eslintConfigFiles, true);
197
246
 
198
- // staged_files = filterFiles(staged_files,exemptionFiles) //this is the code for giving exemption to a file during pre commit
199
- // if(staged_files.length === 0){
247
+ // staged_filesJS = filterFiles(staged_filesJS,exemptionFiles) //this is the code for giving exemption to a file during pre commit
248
+ // if(staged_filesJS.length === 0){
200
249
  // Logger.log(Logger.SUCCESS_TYPE,`Commit Successful`)
201
250
  // process.exit(0)
202
251
  // }
203
252
  areFilesStaged = true;
204
- for (let file in staged_files) {
205
- let currentFileName = staged_files[file];
253
+ var stagedFiles = [...staged_filesJS, ...CssFiles];
254
+ for (let file in stagedFiles) {
255
+ let currentFileName = stagedFiles[file];
206
256
  let changedLinesArray = [];
207
257
  let eslintErrorsInChangedLines = [];
208
258
  let isOnlyEslintWarningsPresentInFile = false;
209
- if (getSupportedLanguage().includes(path.extname(staged_files[file]))) {
259
+ if (getSupportedLanguage().includes(path.extname(stagedFiles[file]))) {
210
260
  try {
211
- var eslintErrorsInFile = await findEslintErrors(staged_files[file]);
212
- // eslintErrorsInFile = impactBasedPrecommit == false ? filterWarningInFile(eslintErrorsInFile) : eslintErrorsInFile
213
- if (staged_files[file] && typeof staged_files[file] == 'string') {
214
- if (!eslintErrorsInFile.length == 0) {
261
+ var errorsInFile = await lintFiles(stagedFiles[file]);
262
+ // eslintErrorsInFile = impactBasedPrecommit == false ? filterWarningInFile(errorsInFile) : errorsInFile
263
+ if (stagedFiles[file] && typeof stagedFiles[file] == 'string') {
264
+ if (!errorsInFile.length == 0) {
215
265
  //Calculating changed lines in a file and storing them in respective arrays
216
266
  if (impactBasedPrecommit) {
217
267
  //git diff is computed and stored in an array
218
- let git_diff = await calculateGitDiffForFile(current_branch, staged_files[file]);
268
+ let git_diff = await calculateGitDiffForFile(current_branch, stagedFiles[file]);
219
269
  changedLinesArray = git_diff.filter(line => line.startsWith('@@'));
220
270
  let changedLinesStartArray = [];
221
271
  let changedLinesEndArray = [];
@@ -229,15 +279,15 @@ async function preCommitHook() {
229
279
  changedLinesEndArray.push(changesStartLine + parseInt(changesEndLine) - 1);
230
280
  }
231
281
  }
232
- for (let error = 1; error < eslintErrorsInFile.length - 2; error++) {
233
- //eslintErrorsInFile[error].trim() - 69:26 error => Do not hardcode content. Use I18N key instead no-hardcoding/no-hardcoding,
234
- //eslintErrorsInFile[error].trim().split(' ')[0] => 69:26
235
- //eslintErrorsInFile[error].trim().split(' ')[0].split(':')[0] => 69
282
+ for (let error = 1; error < errorsInFile.length - 2; error++) {
283
+ //errorsInFile[error].trim() - 69:26 error => Do not hardcode content. Use I18N key instead no-hardcoding/no-hardcoding,
284
+ //errorsInFile[error].trim().split(' ')[0] => 69:26
285
+ //errorsInFile[error].trim().split(' ')[0].split(':')[0] => 69
236
286
 
237
- let eslintErrorLineNumber = eslintErrorsInFile[error].trim().split(' ')[0].split(':')[0];
287
+ let eslintErrorLineNumber = errorsInFile[error].trim().split(' ')[0].split(':')[0];
238
288
  for (let lineNumber in changedLinesStartArray) {
239
289
  if (eslintErrorLineNumber >= changedLinesStartArray[lineNumber] && eslintErrorLineNumber <= changedLinesEndArray[lineNumber]) {
240
- eslintErrorsInChangedLines.push(eslintErrorsInFile[error]);
290
+ eslintErrorsInChangedLines.push(errorsInFile[error]);
241
291
  }
242
292
  }
243
293
  }
@@ -258,10 +308,10 @@ async function preCommitHook() {
258
308
  }
259
309
  }
260
310
  } else {
261
- if (eslintErrorsInFile.length > 0) {
311
+ if (errorsInFile.length > 0) {
262
312
  let startIndex = 1;
263
- let endIndex = eslintErrorsInFile.length - 2;
264
- let listOsEslintErrors = eslintErrorsInFile.slice(startIndex, endIndex);
313
+ let endIndex = errorsInFile.length - 2;
314
+ let listOsEslintErrors = errorsInFile.slice(startIndex, endIndex);
265
315
  isOnlyEslintWarningsPresentInFile = isOnlyWarningsPresentInFile(listOsEslintErrors);
266
316
  Logger.log(Logger.FAILURE_TYPE, `\x1b[1m${currentFileName}\x1b[0m`);
267
317
  for (let eslintError of listOsEslintErrors) {
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ const {
4
+ getLastCommitHash,
5
+ getStoredCommitHash
6
+ } = require("../utils/General/getGeneralInfo");
7
+ const {
8
+ executeMethodsThatReturnBooleanValue
9
+ } = require("../utils/General/wrapperFunctionToExecuteAFunction");
10
+ const {
11
+ cloneViaCdt
12
+ } = require("../utils/CloneCommonLinterRepo/cloneViaCdt");
13
+ const {
14
+ checkIfPluginsAreInstalled
15
+ } = require("../utils/PluginsInstallation/checkIfPluginsAreInstalled");
16
+ const {
17
+ installPlugins
18
+ } = require("../utils/PluginsInstallation/installPlugins");
19
+ async function hooks() {
20
+ if (!(getLastCommitHash() == getStoredCommitHash())) {
21
+ await executeMethodsThatReturnBooleanValue("Make sure zgit.csez.zohocorpin.com is accessible", cloneViaCdt, null);
22
+ const {
23
+ uninstalledPlugins
24
+ } = checkIfPluginsAreInstalled();
25
+ await executeMethodsThatReturnBooleanValue("Some issue occurred in installing plugins", installPlugins, uninstalledPlugins);
26
+ }
27
+ require('./Precommit/pre-commit');
28
+ }
29
+ hooks();
@@ -3,7 +3,9 @@
3
3
  const {
4
4
  Logger
5
5
  } = require('../Logger/Logger');
6
-
6
+ const {
7
+ existsSync
8
+ } = require("fs");
7
9
  /**
8
10
  * @function filterFiles - removes certain files from set of source files
9
11
  * @param {Array} arrayOfFilesToBeFiltered - array of files which must be filtered
@@ -12,6 +14,29 @@ const {
12
14
  * @returns {Array} - containing the resultant set of files after filtering
13
15
  */
14
16
  function filterFiles(arrayOfFilesToBeFiltered, filesToBeRemoved, isConfigFileNeedToBeRemoved = false) {
17
+ /**
18
+ * @function filterFilesByExtension - filter javascript files. omit feature files
19
+ * @param {Array<String>} lintFiles - linter files as Array
20
+ * @returns {Array<String>}
21
+ * */
22
+ function filterFilesByExtension(lintFiles) {
23
+ return lintFiles.reduce((files, currentFile) => {
24
+ if (currentFile.includes('.feature') && existsSync(currentFile)) {
25
+ files.featureFiles.push(currentFile);
26
+ }
27
+ if (currentFile.includes('.js') || currentFile.includes('.ts') || currentFile.includes('.tsx') || currentFile.includes('.jsx') && existsSync(currentFile)) {
28
+ files.JsFiles.push(currentFile);
29
+ }
30
+ if (currentFile.includes('.css') && existsSync(currentFile)) {
31
+ files.CssFiles.push(currentFile);
32
+ }
33
+ return files;
34
+ }, {
35
+ featureFiles: [],
36
+ JsFiles: [],
37
+ CssFiles: []
38
+ });
39
+ }
15
40
  if (filesToBeRemoved.length !== 0) {
16
41
  if (isConfigFileNeedToBeRemoved) {
17
42
  arrayOfFilesToBeFiltered.filter(file => {
@@ -31,7 +56,7 @@ function filterFiles(arrayOfFilesToBeFiltered, filesToBeRemoved, isConfigFileNee
31
56
  return false;
32
57
  }
33
58
  });
34
- return filteredArrayofFilesWithoutConfigFile;
59
+ return filterFilesByExtension(filteredArrayofFilesWithoutConfigFile);
35
60
  } else if (filesToBeRemoved.length === 0) {
36
61
  return arrayOfFilesToBeFiltered;
37
62
  }
@@ -58,7 +58,13 @@ function getSupportedLanguage() {
58
58
  supportedExtensions
59
59
  } = getConfigurationPrecommit();
60
60
  const _language = supportedExtensions;
61
- return _language;
61
+ _language.push('.js');
62
+ _language.push('.jsx');
63
+ _language.push('.ts');
64
+ _language.push('.tsx');
65
+ _language.push('.css');
66
+ _language.push('.scss');
67
+ return [...new Set(_language)];
62
68
  }
63
69
  function getRunningEnv() {
64
70
  const command = "npm config get lint_env";
@@ -45,7 +45,7 @@ function installPlugins(pluginsToBeInstalled) {
45
45
  return true;
46
46
  } else {
47
47
  Logger.log(Logger.FAILURE_TYPE, 'Unable to restore package.json content');
48
- // return false
48
+ return false;
49
49
  }
50
50
  } else {
51
51
  Logger.log(Logger.FAILURE_TYPE, "Unable to install plugins. Kindly retry the command");
@@ -0,0 +1 @@
1
+ node_modules
@@ -0,0 +1,13 @@
1
+ {
2
+ "printWidth": 150,
3
+ "tabWidth": 2,
4
+ "useTabs": false,
5
+ "semi": true,
6
+ "singleQuote": true,
7
+ "jsxSingleQuote": true,
8
+ "trailingComma": "none",
9
+ "bracketSpacing": true,
10
+ "arrowParens": "avoid",
11
+ "endOfLine": "lf"
12
+ }
13
+
@@ -0,0 +1,18 @@
1
+ const { rulesConfig, plugins, extendPlugins } = require("@zohodesk/codestandard-validator"); //no i18n
2
+ const [off, , error] = ["off", "warn", "error"];
3
+ module.exports = {
4
+ env: {
5
+ browser: true,
6
+ es2021: true,
7
+ },
8
+ extends: extendPlugins,
9
+ parserOptions: {
10
+ ecmaFeatures: {
11
+ jsx: true,
12
+ },
13
+ ecmaVersion: 12,
14
+ sourceType: "module",
15
+ },
16
+ plugins: plugins,
17
+ overrides: rulesConfig
18
+ };
@@ -0,0 +1,8 @@
1
+ const $plugins = require('./pluginVersion')
2
+
3
+
4
+ module.exports = {
5
+ rulesConfig : Object.assign([],[]),
6
+ plugins:$plugins.map((plugin) => plugin?.plugin).filter(item => item !== undefined) ,
7
+ extendPlugins:$plugins.map((plugin) => plugin?.extend).filter(item => item !== undefined)
8
+ }
@@ -0,0 +1,3 @@
1
+ module.exports = [
2
+
3
+ ];
@@ -0,0 +1,23 @@
1
+ const { rulesConfig, plugins, extendPlugins } = require("@zohodesk/codestandard-validator"); //no i18n
2
+ const [off, , error] = ["off", "warn", "error"];
3
+ module.exports = {
4
+ env: {
5
+ browser: true,
6
+ es2021: true,
7
+ },
8
+ extends: extendPlugins,
9
+ parserOptions: {
10
+ ecmaFeatures: {
11
+ jsx: true,
12
+ },
13
+ ecmaVersion: 12,
14
+ sourceType: "module",
15
+ },
16
+ plugins: plugins,
17
+ overrides: rulesConfig,
18
+ settings: {
19
+ react: {
20
+ version: "16",
21
+ },
22
+ },
23
+ };
@@ -0,0 +1,25 @@
1
+ const { plugins, rulesConfig } = require("../../common/index");
2
+ const {
3
+ i18nConfiguration,
4
+ } = require("./rule_configuration/i18nRules/noHardcodingRuleExcludes");
5
+ const cssRuleConfiguration = require("./rule_configuration/css_rules/cssRuleConfiguration")
6
+ const unUsedImport = require("./rule_configuration/unUsed/unUsedImport")
7
+ const $plugins = [...require("./pluginVersion"), ...plugins];
8
+
9
+ module.exports = {
10
+ rulesConfig: Object.assign(
11
+ [],
12
+ [
13
+ ...unUsedImport,
14
+ ...cssRuleConfiguration,
15
+ ...rulesConfig,
16
+ ...i18nConfiguration
17
+ ]
18
+ ),
19
+ plugins: $plugins
20
+ .map((plugin) => plugin?.plugin)
21
+ .filter((item) => item !== undefined),
22
+ extendPlugins: $plugins
23
+ .map((plugin) => plugin?.extend)
24
+ .filter((item) => item !== undefined),
25
+ };
@@ -0,0 +1,16 @@
1
+ module.exports = [
2
+ {
3
+ packageName: "@zohodesk/eslint-plugin-no-hardcoding",
4
+ version: "1.0.6",
5
+ plugin: "@zohodesk/no-hardcoding"
6
+ }, {
7
+ packageName: "eslint-plugin-css-modules",
8
+ version: "2.12.0",
9
+ plugin: "css-modules"
10
+ },
11
+ {
12
+ packageName: "eslint-plugin-unused-imports",
13
+ version: "3.2.0",
14
+ plugin: "unused-imports"
15
+ }
16
+ ];
@@ -0,0 +1,15 @@
1
+ const [error, , off, warn] = ['error', '', 'off', 'warn']
2
+
3
+ module.exports = [
4
+ {
5
+ files: ['./PrivateExtensions/**/*.css', './PublicExtensions/**/*.css', './PublicExtensions/**/*.js','./PrivateExtensions/**/*.js'],
6
+ excludedFiles: [
7
+ './PrivateExtensions/**/*.png',
8
+ './PublicExtensions/**/*.png'
9
+ ],
10
+ rules: {
11
+ 'css-modules/no-unused-class': [warn, { "camelCase": true }],
12
+ 'css-modules/no-undef-class': [warn, { "camelCase": true }]
13
+ }
14
+ }
15
+ ]
@@ -0,0 +1,41 @@
1
+ let noHardcodingRuleExcludes = {
2
+ objectKeys:["dataId","data-id","data-test-id","size","iconSize","iconName","align","alignBox","palette","scroll","boxSize","boxPosition","type","moduleName","apiname","apiName","id","target","tagName","module","folderName","componentGroup","hoverType","tabIndex","aria-Label","aria-label","ariaLabel","d","className","rel","heading","column","row","transform","color","condition","fieldName","animationStyle","textBoxVariant","searchBoxSize","src","display","href","width","height","enctype","target","left","top","position","location","backgroundColor","visibility","cursor","lineHeight","border","readOnly","textAlign","scrolling","class","padding","overflow","textBoxSize","right","top","bottom","left","fieldType","regex","searchModuleFieldName","searchConditionValue","logoName","_id","hash","borderColor","variant","paddingSize","paddingLeftSize","ui_displayMode","$ui_displayMode","ui_alignItems","$ui_alignItems","ui_weight","$ui_weight","ui_wrapMode","$ui_wrapMode","ui_scroll","$ui_scroll","ui_direction","$ui_direction","ui_justifyContent","$ui_justifyContent","ui_textAlign","$ui_textAlign","ui_className","$ui_className","ui_hoverType","$ui_hoverType","ui_tagName","$ui_tagName","ui_size","$ui_size","wrap","fontWeight","errorType","shape","ui_boxSize","$ui_boxSize","ui_transform","$ui_transform","iconButtonHoverType","textField","valueField","titlePosition","mode","role","$ui_display"],
3
+ props:["dataId","data-id","data-test-id","size","iconSize","iconName","align","alignBox","palette","scroll","boxSize","boxPosition","type","moduleName","apiname","apiName","id","target","tagName","module","folderName","componentGroup","hoverType","tabIndex","aria-Label","aria-label","ariaLabel","d","className","rel","heading","column","row","transform","color","condition","fieldName","animationStyle","textBoxVariant","searchBoxSize","src","display","href","width","height","enctype","target","left","top","position","location","backgroundColor","visibility","cursor","lineHeight","border","readOnly","textAlign","scrolling","class","padding","overflow","textBoxSize","right","top","bottom","left","fieldType","regex","searchModuleFieldName","searchConditionValue","logoName","_id","hash","borderColor","variant","paddingSize","paddingLeftSize","ui_displayMode","$ui_displayMode","ui_alignItems","$ui_alignItems","ui_weight","$ui_weight","ui_wrapMode","$ui_wrapMode","ui_scroll","$ui_scroll","ui_direction","$ui_direction","ui_justifyContent","$ui_justifyContent","ui_textAlign","$ui_textAlign","ui_className","$ui_className","ui_hoverType","$ui_hoverType","ui_tagName","$ui_tagName","ui_size","$ui_size","wrap","fontWeight","errorType","shape","ui_boxSize","$ui_boxSize","ui_transform","$ui_transform","iconButtonHoverType","textField","valueField","titlePositions","mode","role","$ui_display"],
4
+ methods:["findIdex","findIndex","includes","getFieldIndex","oneOf","oneOfType","bind","getFieldLabel","addEventListener","removeEventListener","replace","split","indexOf","set","selectn","getAdditionalProperty","reject","sendResponse","resolve","mapStateToProps","setAttribute","updateError","concat","createElement","getproperty","addElement","getElementsByName","match","lastIndexOf","setRequestHeader","getParameter","getAttribute","RegExp","substring","equals","log","debug","addClass","open","find","setTimeout","attachEvent","addEventListener","removeAttribute","parseInt","replace","setInterval","getObj","detachEvent","removeEventListener","css","animate","bind","ajaxNew","set_cookie","getElementById","ajax","find","createTextNode","parents","removeClass","toggleClass","write","get_cookie","parseFromString","Error","error","querySelector","getDeptBasedData","timeEnd","time","deskCustomError"],
5
+ allowedTags:["svg"],
6
+ keys:["Product Category","Product Owner","Product Information","Summarize information","and then","and finally","Support Manager","Newbie Agent","Light Agent","All Accounts","All Contacts","All Cases","Open Cases","Closed Cases","My Cases","All Products","Published Solutions","Open Tasks","All Published Solutions","My Draft Solutions","My Review Solutions","Today+Overdue Tasks","Overdue Cases","My Overdue Cases","Spam Cases","Requests for review","Customer Responded Requests","Customer Responded Time","Unassigned Open Requests","Unassigned Open Cases","SLAViolated Requests","My Open Requests","My Accounts","My Contacts","My Products","All Solutions","My Solutions","All Tasks","My Open Tasks","Todays Tasks","Unpublished Solutions","Overdue Tasks","Tomorrows Tasks","All Contracts","Expired Contracts","My Contracts","My Tasks","Completed Tasks","Missed Chats","All Missed Calls","My Missed Calls","Accounts Unmapped with CRM","Accounts Mapped with CRM","Contacts Unmapped with CRM","Contacts Mapped with CRM","Agent Notification","Contact Notification","Contact Created Time","Public Email Templates","Request has been assigned to you","Request for review","Request moved to the Department","Team Notification","Secondary Contacts Notification","Created By","Created Time","Modified Time","Last Activity Time","Unsubscribed Mode","Unsubscribed Time","Reports To","Date of Birth","New Request Created","Your request has been closed","Requestor has replied to the request","Comment Added for the Request","Comment is deleted from a ticket","Comment is edited in a ticket","Resolution Updated for the Request","Notify support reps on new request","Notify Agent when a comment is deleted for their ticket","Notify Agent when a comment is edited from their ticket","Acknowledge contact on receiving a new ticket","Notify agent on assigning a task","Notify agents when a ticket is moved to their department","Notify all agents when a new ticket is created","Notify contact when a comment is added","Notify contact when a comment is deleted","Notify contact when a comment is edited","Notify contact when a resolution is added","Task has been assigned to you","Remind Task Owner on Set Time","Popular Articles","Remind At","User Information","To Address","Account Name","Contact Information",
7
+ "All Requests","Product Code","Product Name","Unit Price","Due Date","Case Number","Not Started","In Progress","Waiting on someone else","On Hold","Contact Name","Last Week","Current Week","Last Month","Current Month","Previous FY","Current FY","Next FY","Previous FQ","Current FQ","Next FQ","Next Week","Next Month","Last 60 Days","Last 90 Days","Last 120 Days","Next 7 Days","Next 30 Days","Next 60 Days","Next 90 Days","Next 120 Days","Full Name","Due on","All User","View Requests","Add Request","View Thread","Paid User","Open in New Window","Recent articles","Contract Name","Contract End","Contract Start","Request Id","Contract Number","Sub Category","support.label.Additional Information","Closed Activities","Recent Views","Modified By","Other Phone","Home Phone","Account Number","Request Subject","Request Charge","Other Address","Mailing Address","Billing Address","Shipping Address","Response Due Date","Unassigned Cases","Case On Hold Time","Summarize information by","and then by","and finally by","Time to Respond","Closing Date","crm.label.Product Category","crm.label.Product Owner","crm.label.Product Information","crm.label.Contact Name","Sub Category","mousemove click","Manufacturer","Hour","Deactivated","Review","Notes","CREATEDTIME","Requests","Social","Reports","Report","Solution","Articles","Article","Customized","Title","Fax","Lookup","Chat","Community","Left","Cases","Solutions","Contract","Accounts","Account","Contacts","Contact","Products","Product","Home","Tasks","Calls","Events","IM","Phone","Mobile","Email","Type","Website","Name","Country","Comments","Priority","Description","Department","click","email","is","are","None","this","these","Total","Category","Pending","Status","Subject","Answer","Overdue","between","Top","Customer","Completed","Deferred","Highest","Lowest","High","Low","Normal","Inactive","Open","New","Web","Draft","Duplicate","Closed","Archived","Today","January","February","March","April","May","June","July","August","September","October","November","December","Jan","Feb","Mar","Apr","Jun","Jul","Aug","Sep","Oct","Nov","Dec","days","day","on","User","Records","Private","AllUsers","Month","Avg","General","and","or","currentDateTime","confirmmsg","maxlenmsg","AM","PM","for","Update","to","Direction","hour","hours","minute",
8
+ "minutes","second","seconds","ago","Move","Unassigned","Expired","Prospect","potential","Lead","Request","Mode","Forums","More","Call","Task","Event","sendingportalinvitation","loading","Custom","loggedinuser_view","everyone_view","onlyagents_view","Agent","Ticket","Attachment","SMS","Subscriptions","ActiveUsersList","DeactivatedUsersList","NotConfirmedUsersList","Content","Created","-None-"],
9
+ commentsToIgnoreHardcodingCheck:["no i18n"],
10
+ stringsAllowedAsBlockCommentStart: ["ignore i18n start","no i18n start"],
11
+ stringsAllowedAsBlockCommentEnd: ["ignore i18n end","no i18n end"],
12
+ dateFormatPatterns:["DD MMM YYYY hh:mm A","DD\/MM\/YYYY h:mm A","DDD, DD MMM YYYY HH:mm:ss","DD MMM YYYY","hh:mm A"],
13
+ startString:["ZD-","zd-","GC-","https","..","ht","flex"],
14
+ allowedPropStartingWords:["is","has","need","animation","dataId"],
15
+ allowedPropEndingWords:["Id","id","size","palette","Palette","Size"],
16
+ allowedWordsThatCanBePresentInAComponentNameToExcludeTheComponent:["Svg"]
17
+ }
18
+ const [error,,off] = ['error','','off']
19
+
20
+ let usegetI18NValueAppropriatelyExcludes = {
21
+ i18nKeys:noHardcodingRuleExcludes.keys,
22
+ commentsToIgnoreCheck:noHardcodingRuleExcludes.commentsToIgnoreHardcodingCheck
23
+ }
24
+
25
+ module.exports.i18nConfiguration = [
26
+ {
27
+ files: ['./PrivateExtensions/**/*.js','./PublicExtensions/**/*.js'],
28
+ excludedFiles: [
29
+ './PrivateExtensions/**/*.png',
30
+ './PublicExtensions/**/*.png',
31
+ './PrivateExtensions/**/*.html',
32
+ './PublicExtensions/**/*.html',
33
+ './PrivateExtensions/**/*.css',
34
+ './PublicExtensions/**/*.css',
35
+ ],
36
+ rules: {
37
+ '@zohodesk/no-hardcoding/no-hardcoding' : [error,{...noHardcodingRuleExcludes}],
38
+ '@zohodesk/no-hardcoding/use-getI18NValue-method-appropriately': [error,{...usegetI18NValueAppropriatelyExcludes}]
39
+ }
40
+ }
41
+ ]
@@ -0,0 +1,14 @@
1
+ const [error, , off, warn] = ['error', '', 'off', 'warn']
2
+
3
+ module.exports = [
4
+ {
5
+ files: ['./PublicExtensions/**/*.js','./PrivateExtensions/**/*.js'],
6
+ excludedFiles: [
7
+ './PrivateExtensions/**/*.png',
8
+ './PublicExtensions/**/*.png'
9
+ ],
10
+ rules: {
11
+ 'unused-imports/no-unused-imports': [error]
12
+ }
13
+ }
14
+ ]
@@ -0,0 +1,21 @@
1
+ const { plugins, rulesConfig } = require('../../common/index');
2
+ const {
3
+ i18nConfiguration
4
+ } = require('./rule_configuration/i18nRules/i18nRules');
5
+ const {
6
+ reactPerformanceRulesConfig
7
+ } = require('./rule_configuration/react-performance-rules/reactPerformanceRulesConfig');
8
+ const $plugins = [...require('./pluginVersion'), ...plugins];
9
+
10
+ module.exports = {
11
+ rulesConfig: Object.assign(
12
+ [],
13
+ [...i18nConfiguration, ...reactPerformanceRulesConfig, ...rulesConfig]
14
+ ),
15
+ plugins: $plugins
16
+ .map((plugin) => plugin?.plugin)
17
+ .filter((item) => item !== undefined),
18
+ extendPlugins: $plugins
19
+ .map((plugin) => plugin?.extend)
20
+ .filter((item) => item !== undefined)
21
+ };
@@ -0,0 +1,12 @@
1
+ module.exports = [
2
+ {
3
+ packageName: '@zohodesk/eslint-plugin-no-hardcoding',
4
+ version: '^1.0.3',
5
+ plugin: '@zohodesk/no-hardcoding'
6
+ },
7
+ {
8
+ packageName: '@zohodesk/eslint-plugin-react-performance',
9
+ version: '^1.0.3',
10
+ plugin: '@zohodesk/react-performance'
11
+ }
12
+ ];