@anolilab/eslint-config 3.0.0 → 4.0.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,34 @@
1
+ ## @anolilab/eslint-config [4.0.0](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/eslint-config@3.0.2...@anolilab/eslint-config@4.0.0) (2022-05-11)
2
+
3
+
4
+ ### ⚠ BREAKING CHANGES
5
+
6
+ * upgraded package to use eslint v8
7
+
8
+ Signed-off-by: prisis <d.bannert@anolilab.de>
9
+
10
+ ### Performance Improvements
11
+
12
+ * upgraded deps and eslint to v8.15 ([94b5859](https://github.com/anolilab/javascript-style-guide/commit/94b585943f729715ddef0b1c2dffe9116c11d626))
13
+
14
+ ### @anolilab/eslint-config [3.0.2](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/eslint-config@3.0.1...@anolilab/eslint-config@3.0.2) (2022-05-06)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **deps:** update dependency @rushstack/eslint-plugin-security to ^0.3.0 ([64f535a](https://github.com/anolilab/javascript-style-guide/commit/64f535abf3aff65debe308ce0d7e88cef163b3d5))
20
+ * **deps:** update dependency eslint-plugin-compat to v4 ([1ae1931](https://github.com/anolilab/javascript-style-guide/commit/1ae193194cb7d9f7bf9f8fdbf626d40056eb1ad2))
21
+ * **deps:** update dependency eslint-plugin-promise to v6 ([913a0bb](https://github.com/anolilab/javascript-style-guide/commit/913a0bb6328a601c5e3243b0ef88f77c050d53c7))
22
+ * **deps:** upgraded deps in all packages ([091353c](https://github.com/anolilab/javascript-style-guide/commit/091353cdd01a0bb3d0e48da9266a6a2978283e2b))
23
+ * fixed eslint config loading of react plugins ([56bc9ce](https://github.com/anolilab/javascript-style-guide/commit/56bc9ce9de8e7fd16d81e7710cdeddc7218b03da))
24
+
25
+ ### @anolilab/eslint-config [3.0.1](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/eslint-config@3.0.0...@anolilab/eslint-config@3.0.1) (2022-02-15)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **deps:** updated all dependencies (non-major) ([6a4e889](https://github.com/anolilab/javascript-style-guide/commit/6a4e889bcdab9d11755b61850e7d24f9f4a0733f))
31
+
1
32
  ## @anolilab/eslint-config [3.0.0](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/eslint-config@2.2.0...@anolilab/eslint-config@3.0.0) (2022-02-15)
2
33
 
3
34
 
package/config.cjs CHANGED
@@ -34,9 +34,8 @@ const depRules = [
34
34
  ["lodash", "lodash-fp"],
35
35
  "jsdoc",
36
36
  "react",
37
- ["mdx", "eslint-plugin-react"],
38
- ["react-a11y", "react"],
39
- ["react-hooks", "react"],
37
+ ["react", "react-a11y"],
38
+ ["react", "react-hooks"],
40
39
  ];
41
40
 
42
41
  const testRules = [
package/index.cjs CHANGED
@@ -12,14 +12,19 @@ if (!global.hasAnolilabEsLintConfigLoaded) {
12
12
  }
13
13
 
14
14
  module.exports = {
15
- extends: rules
16
- .map((plugin) => path.join(__dirname, `./rules/${plugin.split("@")[0]}.cjs`))
17
- .concat(pluginRules.map((plugin) => path.join(__dirname, `./rules/plugins/${plugin.split("@")[0]}.cjs`))),
15
+ extends: [
16
+ ...rules
17
+ // eslint-disable-next-line no-undef
18
+ .map((plugin) => path.join(__dirname, `./rules/${plugin.split("@")[0]}.cjs`)),
19
+ // eslint-disable-next-line no-undef
20
+ ...pluginRules.map((plugin) => path.join(__dirname, `./rules/plugins/${plugin.split("@")[0]}.cjs`)),
21
+ ],
18
22
  // @see https://www.npmjs.com/package/@rushstack/eslint-plugin-security
19
23
  plugins: ["@rushstack/eslint-plugin-security"],
20
24
  rules: {
21
25
  // This is disabled for tools because, for example, it is a common and safe practice for a tool
22
26
  // to read a RegExp from a config file and use it to filter files paths.
27
+ // eslint-disable-next-line no-undef
23
28
  "@rushstack/security/no-unsafe-regexp": process.env.TRUSTED_TOOL ? "off" : "warn",
24
29
  },
25
30
  parserOptions: {
@@ -1,14 +1,14 @@
1
- const isModuleAvailable = require('./is-module-available.cjs');
2
- const { consoleLog } = require('./loggers.cjs');
1
+ const isModuleAvailable = require("./is-module-available.cjs");
2
+ const { consoleLog } = require("./loggers.cjs");
3
3
 
4
- const moduleNotAvailable = (package_) => !isModuleAvailable(package_.split('@')[0]);
4
+ const moduleNotAvailable = (package_) => !isModuleAvailable(package_.split("@")[0]);
5
5
 
6
- const atLatest = (pkg) => {
7
- if (pkg.split('@').indexOf('@') === -1) {
8
- return `${pkg}@latest`;
6
+ const atLatest = (package_) => {
7
+ if (!package_.split("@").includes("@")) {
8
+ return `${package_}@latest`;
9
9
  }
10
10
 
11
- return pkg;
11
+ return package_;
12
12
  };
13
13
 
14
14
  module.exports = function checkMissing(rules, extraInstallPackage) {
@@ -26,21 +26,21 @@ module.exports = function checkMissing(rules, extraInstallPackage) {
26
26
  return;
27
27
  }
28
28
 
29
- const s = notInstalled.length === 1 ? '' : 's';
29
+ const s = notInstalled.length === 1 ? "" : "s";
30
30
 
31
31
  consoleLog(`\nOops! Something went wrong! :(
32
32
 
33
- @anolilab\/eslint-config could not find the following package${s}
33
+ @anolilab/eslint-config could not find the following package${s}
34
34
 
35
- ${notInstalled.join('\n ')}
35
+ ${notInstalled.join("\n ")}
36
36
 
37
37
  To install the missing package${s}, please run the following command:
38
38
 
39
- npm install ${notInstalled.map(atLatest).join(' ')} --save-dev
39
+ npm install ${notInstalled.map((element) => atLatest(element)).join(" ")} --save-dev
40
40
 
41
41
  or
42
42
 
43
- yarn add ${notInstalled.map(atLatest).join(' ')} --dev
43
+ yarn add ${notInstalled.map((element) => atLatest(element)).join(" ")} --dev
44
44
 
45
45
  `);
46
46
 
@@ -2,7 +2,7 @@ module.exports = function isModuleAvailable(name) {
2
2
  try {
3
3
  require.resolve(name);
4
4
  return true;
5
- } catch (error) {
5
+ } catch {
6
6
  return false;
7
7
  }
8
8
  };
package/lib/loggers.cjs CHANGED
@@ -2,11 +2,11 @@
2
2
  const noop = () => undefined;
3
3
 
4
4
  const consolePrefix = (prefix) =>
5
- // eslint-disable-next-line no-console
6
- Boolean(process.env.NO_LOGS) ? noop : (file) => console.log(`${prefix}${file}`);
5
+ // eslint-disable-next-line no-console,implicit-arrow-linebreak,no-undef
6
+ (process.env.NO_LOGS ? noop : (file) => console.log(`${prefix}${file}`));
7
7
 
8
8
  module.exports = {
9
- consolePlugin: consolePrefix(' eslint-plugin-'),
10
- consoleConfig: consolePrefix(' eslint-config-'),
11
- consoleLog: consolePrefix('')
12
- }
9
+ consolePlugin: consolePrefix(" eslint-plugin-"),
10
+ consoleConfig: consolePrefix(" eslint-config-"),
11
+ consoleLog: consolePrefix(""),
12
+ };
@@ -1,26 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // eslint-disable-next-line no-undef
3
4
  if (process.env.CI) {
5
+ // eslint-disable-next-line no-undef
4
6
  process.exit(0);
5
7
  }
6
8
 
7
- const { writeFile, existsSync } = require('fs');
8
- const { resolve, join } = require('path');
9
- const { promisify } = require('util');
10
- const { hasAnyDep } = require('./utils.cjs');
9
+ const { writeFile, existsSync } = require("fs");
10
+ // eslint-disable-next-line unicorn/import-style
11
+ const { resolve, join } = require("path");
12
+ const { promisify } = require("util");
11
13
 
12
14
  const writeFileAsync = promisify(writeFile);
13
15
 
14
16
  // get the path to the host project.
15
- const projectPath = resolve(process.cwd(), '..', '..', '..');
17
+ // eslint-disable-next-line no-undef
18
+ const projectPath = resolve(process.cwd(), "..", "..", "..");
16
19
 
17
- console.log('Configuring @anolilab/eslint-config', projectPath, '\n');
20
+ console.log("Configuring @anolilab/eslint-config", projectPath, "\n");
18
21
 
19
22
  /**
20
23
  * Writes .eslintrc.cjs if it doesn't exist. Warns if it exists.
21
24
  */
22
25
  const writeEslintRc = () => {
23
- const eslintPath = join(projectPath, '.eslintrc.cjs');
26
+ const eslintPath = join(projectPath, ".eslintrc.cjs");
24
27
  const content = `module.exports = {
25
28
  root: true,
26
29
  extends: ["@anolilab/eslint-config"],
@@ -52,104 +55,38 @@ to work as it should: { extends: ["@anolilab/eslint-config"] }.`);
52
55
  return Promise.resolve();
53
56
  }
54
57
 
55
- return writeFileAsync(eslintPath, content, 'utf-8');
58
+ return writeFileAsync(eslintPath, content, "utf-8");
56
59
  };
57
60
 
58
61
  /**
59
- * Writes .prettierrc.cjs if it doesn't exist. Warns if it exists.
62
+ * Writes .eslintignore if it doesn't exist. Warns if it exists.
60
63
  */
61
- const writePrettierRc = () => {
62
- const prettierPath = join(projectPath, '.prettierrc.cjs');
63
- const content = {
64
- // max 120 characters per line
65
- printWidth: 120,
66
- // use 2 spaces for indentation
67
- tabWidth: 4,
68
- // use spaces instead of indentations
69
- useTabs: false,
70
- // semicolon at the end of the line
71
- semi: true,
72
- // use single quotes
73
- singleQuote: false,
74
- // object's key is quoted only when necessary
75
- quoteProps: 'as-needed',
76
- // use double quotes instead of single quotes in jsx
77
- jsxSingleQuote: false,
78
- // no comma at the end
79
- trailingComma: 'all',
80
- // spaces are required at the beginning and end of the braces
81
- bracketSpacing: true,
82
- // end tag of jsx need to wrap
83
- jsxBracketSameLine: false,
84
- // brackets are required for arrow function parameter, even when there is only one parameter
85
- arrowParens: 'always',
86
- // format the entire contents of the file
87
- rangeStart: 0,
88
- rangeEnd: Infinity,
89
- // no need to write the beginning @prettier of the file
90
- requirePragma: false,
91
- // No need to automatically insert @prettier at the beginning of the file
92
- insertPragma: false,
93
- // use default break criteria
94
- proseWrap: 'preserve',
95
- // decide whether to break the html according to the display style
96
- htmlWhitespaceSensitivity: 'css',
97
- // vue files script and style tags indentation
98
- vueIndentScriptAndStyle: false,
99
- // lf for newline
100
- endOfLine: 'lf',
101
- // formats quoted code embedded
102
- embeddedLanguageFormatting: 'auto',
103
- };
104
-
105
- if (existsSync(prettierPath) || existsSync(prettierPath.replace('.js', ''))) {
106
- console.warn(`⚠️ .prettierrc.js already exists;
107
- Make sure that it includes the following for @anolilab/eslint-config to work as it should:
108
- ${JSON.stringify(content, null, 4)}\n`);
64
+ const writeEslintIgnore = () => {
65
+ const eslintIgnorePath = join(projectPath, ".eslintignore");
109
66
 
110
- return Promise.resolve();
111
- }
112
-
113
- return writeFileAsync(
114
- prettierPath,
115
- `module.exports = ${JSON.stringify(content, null, 2)}\n`,
116
- 'utf-8',
117
- );
118
- };
119
-
120
- /**
121
- * Writes .prettierignore if it doesn't exist. Warns if it exists.
122
- */
123
- const writePrettierIgnore = () => {
124
- const prettierPath = join(projectPath, '.prettierignore');
125
-
126
- if (existsSync(prettierPath)) {
127
- console.warn(`⚠️ .prettierignore already exists`);
67
+ if (existsSync(eslintIgnorePath)) {
68
+ console.warn("⚠️ .eslintignore already exists");
128
69
 
129
70
  return Promise.resolve();
130
71
  }
131
72
 
132
- return writeFileAsync(prettierPath, "", "utf-8");
73
+ return writeFileAsync(eslintIgnorePath, "", "utf-8");
133
74
  };
134
75
 
135
76
  (async () => {
136
77
  try {
137
- const promises = [writeEslintRc()];
138
-
139
- if (hasAnyDep("prettier")) {
140
- promises.push(writePrettierRc());
141
- promises.push(writePrettierIgnore())
142
- }
143
-
144
- await Promise.all(promises);
78
+ // eslint-disable-next-line compat/compat
79
+ await Promise.all([writeEslintRc(), writeEslintIgnore()]);
145
80
 
146
81
  console.log("😎 Everything went well, have fun!");
147
82
 
83
+ // eslint-disable-next-line no-undef
148
84
  process.exit(0);
149
- } catch (err) {
85
+ } catch (error) {
150
86
  console.log("😬 something went wrong:");
151
- console.error(err.message);
87
+ console.error(error.message);
152
88
 
89
+ // eslint-disable-next-line no-undef
153
90
  process.exit(1);
154
91
  }
155
92
  })();
@@ -1,4 +1,4 @@
1
- const { consoleLog, consolePlugin } = require('./loggers.cjs');
1
+ const { consoleLog, consolePlugin } = require("./loggers.cjs");
2
2
 
3
3
  module.exports = function showLoaded(rules, extraInstallPackage) {
4
4
  extraInstallPackage.forEach(([rule, package_]) => {
@@ -7,7 +7,7 @@ module.exports = function showLoaded(rules, extraInstallPackage) {
7
7
  }
8
8
  });
9
9
 
10
- consoleLog('\n@anolilab\/eslint-config loaded the following packages:\n');
10
+ consoleLog("\n@anolilab/eslint-config loaded the following packages:\n");
11
11
 
12
- rules.forEach(consolePlugin);
12
+ rules.forEach((element) => { consolePlugin(element); });
13
13
  };
package/lib/utils.cjs CHANGED
@@ -1,51 +1,60 @@
1
1
  // From kcd-scripts
2
- const { existsSync, realpathSync } = require('fs');
3
- const { dirname, join } = require('path');
4
- const has = require('lodash.has');
5
- const readPkgUp = require('read-pkg-up');
2
+ const { existsSync, realpathSync } = require("fs");
3
+ // eslint-disable-next-line unicorn/import-style
4
+ const { dirname, join } = require("path");
5
+ // eslint-disable-next-line lodash/import-scope
6
+ const has = require("lodash.has");
7
+ const readPkgUp = require("read-pkg-up");
6
8
 
7
9
  function arrify(value) {
8
- if (value === null || value === undefined) {
9
- return [];
10
- }
10
+ if (value === null || value === undefined) {
11
+ return [];
12
+ }
11
13
 
12
- if (Array.isArray(value)) {
13
- return value;
14
- }
14
+ if (Array.isArray(value)) {
15
+ return value;
16
+ }
15
17
 
16
- if (typeof value === 'string') {
17
- return [value];
18
- }
18
+ if (typeof value === "string") {
19
+ return [value];
20
+ }
19
21
 
20
- if (typeof value[Symbol.iterator] === 'function') {
21
- return [...value];
22
- }
22
+ if (typeof value[Symbol.iterator] === "function") {
23
+ return [...value];
24
+ }
23
25
 
24
- return [value];
26
+ return [value];
25
27
  }
26
28
 
29
+ // eslint-disable-next-line @typescript-eslint/naming-convention
27
30
  const { packageJson: package_, path: packagePath } = readPkgUp.sync({
31
+ // eslint-disable-next-line no-undef
28
32
  cwd: realpathSync(process.cwd()),
29
33
  });
30
- const hasPackageProperty = (properties) =>
31
- arrify(properties).some((property) => has(package_, property)); // eslint-disable-line lodash-fp/no-extraneous-function-wrapping
34
+ // eslint-disable-next-line max-len
35
+ const hasPackageProperty = (properties) => arrify(properties).some((property) => has(package_, property)); // eslint-disable-line lodash-fp/no-extraneous-function-wrapping
32
36
 
33
- const hasPackageSubProperty = (packageProperty) => (properties) =>
34
- hasPackageProperty(arrify(properties).map((p) => `${packageProperty}.${p}`));
37
+ const hasPackageSubProperty = (packageProperty) => (properties) => hasPackageProperty(arrify(properties).map((p) => `${packageProperty}.${p}`));
35
38
 
36
39
  function environmentIsSet(name) {
37
40
  return (
38
- process.env.hasOwnProperty(name) && // eslint-disable-line no-prototype-builtins
39
- process.env[name] &&
40
- process.env[name] !== 'undefined'
41
+ // eslint-disable-next-line no-undef
42
+ process.env.hasOwnProperty(name) // eslint-disable-line no-prototype-builtins
43
+ // eslint-disable-next-line no-undef
44
+ && process.env[name]
45
+ // eslint-disable-next-line no-undef
46
+ && process.env[name] !== "undefined"
41
47
  );
42
48
  }
43
49
 
50
+ // eslint-disable-next-line unicorn/prevent-abbreviations
44
51
  function parseEnvironment(name, def) {
45
52
  if (environmentIsSet(name)) {
46
53
  try {
54
+ // eslint-disable-next-line no-undef
47
55
  return JSON.parse(process.env[name]);
48
- } catch (error) {
56
+ } catch {
57
+ // eslint-disable-next-line no-undef
49
58
  return process.env[name];
50
59
  }
51
60
  }
@@ -55,12 +64,12 @@ function parseEnvironment(name, def) {
55
64
  const appDirectory = dirname(packagePath);
56
65
  const fromRoot = (...p) => join(appDirectory, ...p);
57
66
  const hasFile = (...p) => existsSync(fromRoot(...p));
58
- const hasScript = hasPackageSubProperty('scripts');
59
- const hasPeerDep = hasPackageSubProperty('peerDependencies');
60
- const hasDep = hasPackageSubProperty('dependencies');
61
- const hasDevelopmentDep = hasPackageSubProperty('devDependencies');
62
- const hasAnyDep = (args) => [hasDep, hasDevelopmentDep, hasPeerDep].some((fn) => fn(args));
63
- const hasTypescript = hasAnyDep('typescript') && hasFile('tsconfig.json');
67
+ const hasScript = hasPackageSubProperty("scripts");
68
+ const hasPeerDep = hasPackageSubProperty("peerDependencies");
69
+ const hasDep = hasPackageSubProperty("dependencies");
70
+ const hasDevelopmentDep = hasPackageSubProperty("devDependencies");
71
+ const hasAnyDep = (arguments_) => [hasDep, hasDevelopmentDep, hasPeerDep].some((function_) => function_(arguments_));
72
+ const hasTypescript = hasAnyDep("typescript") && hasFile("tsconfig.json");
64
73
 
65
74
  module.exports = {
66
75
  uniq: function uniq(array) {
@@ -78,4 +87,4 @@ module.exports = {
78
87
  hasDevelopmentDep,
79
88
  hasAnyDep,
80
89
  hasTypescript,
81
- }
90
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anolilab/eslint-config",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "ESLint shareable config for the Anolilab JavaScript style guide.",
5
5
  "keywords": [
6
6
  "css",
@@ -54,78 +54,78 @@
54
54
  "postinstall": "node lib/postinstall.cjs"
55
55
  },
56
56
  "dependencies": {
57
- "@rushstack/eslint-plugin-security": "^0.2.2",
58
- "confusing-browser-globals": "^1.0.10",
57
+ "@rushstack/eslint-plugin-security": "^0.3.0",
58
+ "confusing-browser-globals": "^1.0.11",
59
59
  "eslint-import-resolver-node": "^0.3.6",
60
- "eslint-plugin-compat": "^3.13.0",
60
+ "eslint-plugin-compat": "^4.0.2",
61
61
  "eslint-plugin-eslint-comments": "^3.2.0",
62
- "eslint-plugin-import": "^2.25.2",
62
+ "eslint-plugin-import": "^2.26.0",
63
63
  "eslint-plugin-markdown": "^2.2.1",
64
64
  "eslint-plugin-no-loops": "^0.3.0",
65
65
  "eslint-plugin-no-secrets": "^0.8.9",
66
66
  "eslint-plugin-optimize-regex": "^1.2.1",
67
- "eslint-plugin-promise": "^5.1.1",
67
+ "eslint-plugin-promise": "^6.0.0",
68
68
  "eslint-plugin-radar": "^0.2.1",
69
69
  "eslint-plugin-simple-import-sort": "^7.0.0",
70
70
  "eslint-plugin-sort-keys-fix": "^1.1.2",
71
- "eslint-plugin-unicorn": "^37.0.1",
71
+ "eslint-plugin-unicorn": "^42.0.0",
72
72
  "eslint-plugin-you-dont-need-lodash-underscore": "^6.12.0",
73
73
  "eslint-plugin-you-dont-need-momentjs": "^1.6.0",
74
74
  "lodash.has": "^4.5.2",
75
75
  "object.assign": "^4.1.2",
76
76
  "read-pkg-up": "7.0.1",
77
- "semver": "^7.3.5"
77
+ "semver": "^7.3.7"
78
78
  },
79
79
  "devDependencies": {
80
- "@testing-library/dom": "8.11.2",
81
- "@typescript-eslint/eslint-plugin": "^5.0.0",
82
- "@typescript-eslint/parser": "5.10.0",
83
- "eslint": "8.7.0",
80
+ "@testing-library/dom": "8.13.0",
81
+ "@typescript-eslint/eslint-plugin": "^5.19.0",
82
+ "@typescript-eslint/parser": "5.23.0",
83
+ "eslint": "8.15.0",
84
84
  "eslint-find-rules": "4.1.0",
85
85
  "eslint-plugin-babel": "5.3.1",
86
86
  "eslint-plugin-cypress": "2.12.1",
87
- "eslint-plugin-jest": "25.7.0",
87
+ "eslint-plugin-jest": "26.1.5",
88
88
  "eslint-plugin-jest-async": "1.0.3",
89
89
  "eslint-plugin-jest-dom": "4.0.1",
90
90
  "eslint-plugin-jest-formatting": "3.1.0",
91
- "eslint-plugin-jsdoc": "37.6.3",
91
+ "eslint-plugin-jsdoc": "39.2.9",
92
92
  "eslint-plugin-json": "3.1.0",
93
93
  "eslint-plugin-jsx-a11y": "6.5.1",
94
- "eslint-plugin-mdx": "1.16.0",
94
+ "eslint-plugin-mdx": "1.17.0",
95
95
  "eslint-plugin-node": "11.1.0",
96
96
  "eslint-plugin-prefer-object-spread": "1.2.1",
97
- "eslint-plugin-react": "7.28.0",
98
- "eslint-plugin-react-hooks": "4.3.0",
99
- "eslint-plugin-react-redux": "3.3.4",
100
- "eslint-plugin-testing-library": "5.0.4",
97
+ "eslint-plugin-react": "7.29.4",
98
+ "eslint-plugin-react-hooks": "4.5.0",
99
+ "eslint-plugin-react-redux": "4.0.0",
100
+ "eslint-plugin-testing-library": "5.4.0",
101
101
  "eslint-plugin-typescript-sort-keys": "2.1.0",
102
- "jest": "27.4.7",
103
- "react": "17.0.2",
104
- "typescript": "^4.4.4"
102
+ "jest": "28.1.0",
103
+ "react": "18.1.0",
104
+ "typescript": "^4.6.4"
105
105
  },
106
106
  "peerDependencies": {
107
107
  "eslint": "^7.32.0"
108
108
  },
109
109
  "optionalDependencies": {
110
- "@typescript-eslint/eslint-plugin": "^5.2.0",
111
- "@typescript-eslint/parser": "^5.2.0",
110
+ "@typescript-eslint/eslint-plugin": "^5.23.0",
111
+ "@typescript-eslint/parser": "^5.23.0",
112
112
  "eslint-plugin-babel": "^5.3.1",
113
113
  "eslint-plugin-cypress": "^2.12.1",
114
- "eslint-plugin-jest": "^25.2.2",
114
+ "eslint-plugin-jest": "^26.1.5",
115
115
  "eslint-plugin-jest-async": "^1.0.3",
116
- "eslint-plugin-jest-dom": "^3.9.2",
117
- "eslint-plugin-jest-formatting": "^3.0.0",
118
- "eslint-plugin-jsdoc": "^37.0.2",
116
+ "eslint-plugin-jest-dom": "^4.0.1",
117
+ "eslint-plugin-jest-formatting": "^3.1.0",
118
+ "eslint-plugin-jsdoc": "^39.2.1",
119
119
  "eslint-plugin-json": "^3.1.0",
120
- "eslint-plugin-jsx-a11y": "^6.4.1",
121
- "eslint-plugin-mdx": "^1.16.0",
120
+ "eslint-plugin-jsx-a11y": "^6.5.1",
121
+ "eslint-plugin-mdx": "^1.17.0",
122
122
  "eslint-plugin-node": "^11.1.0",
123
123
  "eslint-plugin-prefer-object-spread": "^1.2.1",
124
- "eslint-plugin-react": "^7.26.1",
125
- "eslint-plugin-react-hooks": "^4.2.0",
126
- "eslint-plugin-react-redux": "^3.3.2",
127
- "eslint-plugin-testing-library": "^5.0.0",
128
- "eslint-plugin-typescript-sort-keys": "^2.0.0"
124
+ "eslint-plugin-react": "^7.29.4",
125
+ "eslint-plugin-react-hooks": "^4.5.0",
126
+ "eslint-plugin-react-redux": "^4.0.0",
127
+ "eslint-plugin-testing-library": "^5.4.0",
128
+ "eslint-plugin-typescript-sort-keys": "^2.1.0"
129
129
  },
130
130
  "engines": {
131
131
  "node": ">=16"
@@ -242,6 +242,7 @@ module.exports = {
242
242
  {
243
243
  object: "global",
244
244
  property: "isFinite",
245
+ // eslint-disable-next-line radar/no-duplicate-string
245
246
  message: "Please use Number.isFinite instead",
246
247
  },
247
248
  {
@@ -257,6 +258,7 @@ module.exports = {
257
258
  {
258
259
  object: "global",
259
260
  property: "isNaN",
261
+ // eslint-disable-next-line radar/no-duplicate-string
260
262
  message: "Please use Number.isNaN instead",
261
263
  },
262
264
  {
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line unicorn/prevent-abbreviations
1
2
  module.exports = {
2
3
  plugins: ["array-func"],
3
4
  extends: ["plugin:array-func/recommended"],
@@ -1,6 +1,6 @@
1
1
  const { rules: baseBestPracticesRules } = require("../best-practices.cjs");
2
- const { rules: errorsRules } = require("../errorsRules.cjs");
3
- const { rules: styleRules } = require("../styleRules.cjs");
2
+ const { rules: errorsRules } = require("../errors.cjs");
3
+ const { rules: styleRules } = require("../style.cjs");
4
4
 
5
5
  module.exports = {
6
6
  plugins: ["babel"],
@@ -103,7 +103,6 @@ module.exports = {
103
103
 
104
104
  // No Node.js builtin modules
105
105
  // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
106
- // TODO: enable?
107
106
  "import/no-nodejs-modules": "off",
108
107
 
109
108
  // Style guide:
@@ -29,6 +29,7 @@ const hasJsxRuntime = (() => {
29
29
  try {
30
30
  require.resolve("react/jsx-runtime.js");
31
31
 
32
+ // eslint-disable-next-line no-undef
32
33
  if (process.env.NO_LOGS === undefined) {
33
34
  console.info(`\n@anolilab/eslint-config found react jsx-runtime. \n
34
35
  Following rules are disabled: "react/jsx-uses-react" and "react/react-in-jsx-scope".
@@ -36,7 +37,7 @@ const hasJsxRuntime = (() => {
36
37
  }
37
38
 
38
39
  return true;
39
- } catch (e) {
40
+ } catch {
40
41
  return false;
41
42
  }
42
43
  })();
@@ -56,7 +57,7 @@ module.exports = {
56
57
  "no-underscore-dangle": [
57
58
  dangleRules[0],
58
59
  assign({}, dangleRules[1], {
59
- allow: dangleRules[1].allow.concat(["__REDUX_DEVTOOLS_EXTENSION_COMPOSE__"]),
60
+ allow: [...dangleRules[1].allow, "__REDUX_DEVTOOLS_EXTENSION_COMPOSE__"],
60
61
  }),
61
62
  ],
62
63
 
@@ -359,6 +360,7 @@ module.exports = {
359
360
  "react/jsx-wrap-multilines": [
360
361
  "error",
361
362
  {
363
+ // eslint-disable-next-line radar/no-duplicate-string
362
364
  declaration: "parens-new-line",
363
365
  assignment: "parens-new-line",
364
366
  return: "parens-new-line",
@@ -389,7 +391,7 @@ module.exports = {
389
391
  // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
390
392
  "react/jsx-filename-extension": [
391
393
  "error",
392
- { extensions: [".jsx"].concat(hasAnyDep("typescript") ? [".tsx"] : []) },
394
+ { extensions: [".jsx", ...(hasAnyDep("typescript") ? [".tsx"] : [])] },
393
395
  ],
394
396
 
395
397
  // prevent accidental JS comments from being injected into JSX as text
@@ -639,7 +641,7 @@ module.exports = {
639
641
  settings: {
640
642
  "import/resolver": {
641
643
  node: {
642
- extensions: [".js", ".jsx", ".json"].concat(hasAnyDep("rect") ? [".ts", ".tsx", ".d.ts"] : []),
644
+ extensions: [".js", ".jsx", ".json", ...(hasAnyDep("rect") ? [".ts", ".tsx", ".d.ts"] : [])],
643
645
  },
644
646
  },
645
647
  react: {
@@ -1,15 +1,10 @@
1
1
  const isModuleAvailable = require("../../lib/is-module-available.cjs");
2
2
  const { consoleLog } = require("../../lib/loggers.cjs");
3
3
 
4
- let ruleset;
4
+ let ruleset = "dom";
5
5
 
6
- switch (true) {
7
- case isModuleAvailable("react"):
8
- ruleset = "react";
9
- break;
10
-
11
- default:
12
- ruleset = "dom";
6
+ if (isModuleAvailable("react")) {
7
+ ruleset = "react";
13
8
  }
14
9
 
15
10
  consoleLog(` eslint-plugin-testing-library/${ruleset}`);
@@ -1,12 +1,15 @@
1
1
  module.exports = {
2
- plugins: ["typescript-sort-keys"],
3
- rules: {
4
- "typescript-sort-keys/interface": "error",
5
- "typescript-sort-keys/string-enum": "error",
6
- },
7
2
  overrides: [
8
3
  {
9
- files: "*.js",
4
+ files: ["*.ts", "*.tsx"],
5
+ plugins: ["typescript-sort-keys"],
6
+ rules: {
7
+ "typescript-sort-keys/interface": "error",
8
+ "typescript-sort-keys/string-enum": "error",
9
+ },
10
+ },
11
+ {
12
+ files: ["*.js", "*.cjs", "*.mjs"],
10
13
  rules: {
11
14
  "typescript-sort-keys/interface": "off",
12
15
  "typescript-sort-keys/string-enum": "off",
@@ -6,244 +6,246 @@ const { rules: baseStyleRules } = require("../style.cjs");
6
6
  const { rules: baseVariablesRules } = require("../variables.cjs");
7
7
 
8
8
  module.exports = {
9
- extends: ["plugin:import/typescript"],
10
- plugins: ["@typescript-eslint"],
11
- parser: "@typescript-eslint/parser",
12
- settings: {
13
- // Apply special parsing for TypeScript files
14
- "import/parsers": {
15
- "@typescript-eslint/parser": [".ts", ".tsx", ".d.ts"],
16
- },
17
- // Append 'ts' extensions to 'import/resolver' setting
18
- "import/resolver": {
19
- node: {
20
- extensions: [".mjs", ".js", ".json", ".ts", ".d.ts"],
21
- },
22
- },
23
- // Append 'ts' extensions to 'import/extensions' setting
24
- "import/extensions": [".js", ".mjs", ".jsx", ".ts", ".tsx", ".d.ts"],
25
- // Resolve type definition packages
26
- "import/external-module-folders": ["node_modules", "node_modules/@types"],
27
- },
28
- rules: {
29
- // Replace 'brace-style' rule with '@typescript-eslint' version
30
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/brace-style.md
31
- "brace-style": "off",
32
- "@typescript-eslint/brace-style": baseStyleRules["brace-style"],
33
-
34
- // Replace 'camelcase' rule with '@typescript-eslint/naming-convention'
35
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
36
- camelcase: "off",
37
- // The `@typescript-eslint/naming-convention` rule allows `leadingUnderscore` and `trailingUnderscore` settings. However, the existing `no-underscore-dangle` rule already takes care of this.
38
- "@typescript-eslint/naming-convention": [
39
- "error",
40
- // Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables (23.10)
41
- {
42
- selector: "variable",
43
- format: ["camelCase", "PascalCase", "UPPER_CASE"],
44
- },
45
- // Allow camelCase functions (23.2), and PascalCase functions (23.8)
46
- {
47
- selector: "function",
48
- format: ["camelCase", "PascalCase"],
49
- },
50
- // recommends PascalCase for classes (23.3), and although does not make TypeScript recommendations, we are assuming this rule would similarly apply to anything "type like", including interfaces, type aliases, and enums
51
- {
52
- selector: "typeLike",
53
- format: ["PascalCase"],
54
- },
55
- ],
56
-
57
- // Replace 'comma-dangle' rule with '@typescript-eslint' version
58
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/comma-dangle.md
59
- // The TypeScript version also adds 3 new options, all of which should be set to the same value as the base config
60
- "comma-dangle": "off",
61
- "@typescript-eslint/comma-dangle": [
62
- baseStyleRules["comma-dangle"][0],
63
- {
64
- ...baseStyleRules["comma-dangle"][1],
65
- enums: baseStyleRules["comma-dangle"][1].arrays,
66
- generics: baseStyleRules["comma-dangle"][1].arrays,
67
- tuples: baseStyleRules["comma-dangle"][1].arrays,
68
- },
69
- ],
70
-
71
- // Replace 'comma-spacing' rule with '@typescript-eslint' version
72
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/comma-spacing.md
73
- "comma-spacing": "off",
74
- "@typescript-eslint/comma-spacing": baseStyleRules["comma-spacing"],
75
-
76
- // Replace 'dot-notation' rule with '@typescript-eslint' version
77
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/dot-notation.md
78
- "dot-notation": "off",
79
- "@typescript-eslint/dot-notation": baseBestPracticesRules["dot-notation"],
80
-
81
- // Replace 'func-call-spacing' rule with '@typescript-eslint' version
82
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/func-call-spacing.md
83
- "func-call-spacing": "off",
84
- "@typescript-eslint/func-call-spacing": baseStyleRules["func-call-spacing"],
85
-
86
- // Replace 'indent' rule with '@typescript-eslint' version
87
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/indent.md
88
- indent: "off",
89
- "@typescript-eslint/indent": baseStyleRules.indent,
90
-
91
- // Replace 'keyword-spacing' rule with '@typescript-eslint' version
92
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/keyword-spacing.md
93
- "keyword-spacing": "off",
94
- "@typescript-eslint/keyword-spacing": baseStyleRules["keyword-spacing"],
95
-
96
- // Replace 'lines-between-class-members' rule with '@typescript-eslint' version
97
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/lines-between-class-members.md
98
- "lines-between-class-members": "off",
99
- "@typescript-eslint/lines-between-class-members": baseStyleRules["lines-between-class-members"],
100
-
101
- // Replace 'no-array-constructor' rule with '@typescript-eslint' version
102
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-array-constructor.md
103
- "no-array-constructor": "off",
104
- "@typescript-eslint/no-array-constructor": baseStyleRules["no-array-constructor"],
105
-
106
- // Replace 'no-dupe-class-members' rule with '@typescript-eslint' version
107
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-dupe-class-members.md
108
- "no-dupe-class-members": "off",
109
- "@typescript-eslint/no-dupe-class-members": baseES6Rules["no-dupe-class-members"],
110
-
111
- // Replace 'no-empty-function' rule with '@typescript-eslint' version
112
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md
113
- "no-empty-function": "off",
114
- "@typescript-eslint/no-empty-function": baseBestPracticesRules["no-empty-function"],
115
-
116
- // Replace 'no-extra-parens' rule with '@typescript-eslint' version
117
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extra-parens.md
118
- "no-extra-parens": "off",
119
- "@typescript-eslint/no-extra-parens": baseErrorsRules["no-extra-parens"],
120
-
121
- // Replace 'no-extra-semi' rule with '@typescript-eslint' version
122
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extra-semi.md
123
- "no-extra-semi": "off",
124
- "@typescript-eslint/no-extra-semi": baseErrorsRules["no-extra-semi"],
125
-
126
- // Replace 'no-implied-eval' and 'no-new-func' rules with '@typescript-eslint' version
127
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-implied-eval.md
128
- "no-implied-eval": "off",
129
- "no-new-func": "off",
130
- "@typescript-eslint/no-implied-eval": baseBestPracticesRules["no-implied-eval"],
131
-
132
- // Replace 'no-loop-func' rule with '@typescript-eslint' version
133
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-loop-func.md
134
- "no-loop-func": "off",
135
- "@typescript-eslint/no-loop-func": baseBestPracticesRules["no-loop-func"],
136
-
137
- // Replace 'no-magic-numbers' rule with '@typescript-eslint' version
138
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-magic-numbers.md
139
- "no-magic-numbers": "off",
140
- "@typescript-eslint/no-magic-numbers": baseBestPracticesRules["no-magic-numbers"],
141
-
142
- // Replace 'no-redeclare' rule with '@typescript-eslint' version
143
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-redeclare.md
144
- "no-redeclare": "off",
145
- "@typescript-eslint/no-redeclare": baseBestPracticesRules["no-redeclare"],
146
-
147
- // Replace 'no-shadow' rule with '@typescript-eslint' version
148
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-shadow.md
149
- "no-shadow": "off",
150
- "@typescript-eslint/no-shadow": baseVariablesRules["no-shadow"],
151
-
152
- // Replace 'no-throw-literal' rule with '@typescript-eslint' version
153
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-throw-literal.md
154
- "no-throw-literal": "off",
155
- "@typescript-eslint/no-throw-literal": baseBestPracticesRules["no-throw-literal"],
156
-
157
- // Replace 'no-unused-expressions' rule with '@typescript-eslint' version
158
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-expressions.md
159
- "no-unused-expressions": "off",
160
- "@typescript-eslint/no-unused-expressions": baseBestPracticesRules["no-unused-expressions"],
161
-
162
- // Replace 'no-unused-vars' rule with '@typescript-eslint' version
163
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
164
- "no-unused-vars": "off",
165
- "@typescript-eslint/no-unused-vars": baseVariablesRules["no-unused-vars"],
166
-
167
- // Replace 'no-use-before-define' rule with '@typescript-eslint' version
168
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
169
- "no-use-before-define": "off",
170
- "@typescript-eslint/no-use-before-define": baseVariablesRules["no-use-before-define"],
171
-
172
- // Replace 'no-useless-constructor' rule with '@typescript-eslint' version
173
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-useless-constructor.md
174
- "no-useless-constructor": "off",
175
- "@typescript-eslint/no-useless-constructor": baseES6Rules["no-useless-constructor"],
176
-
177
- // Replace 'quotes' rule with '@typescript-eslint' version
178
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/quotes.md
179
- quotes: "off",
180
- "@typescript-eslint/quotes": baseStyleRules.quotes,
181
-
182
- // Replace 'semi' rule with '@typescript-eslint' version
183
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/semi.md
184
- semi: "off",
185
- "@typescript-eslint/semi": baseStyleRules.semi,
186
-
187
- // Replace 'space-before-function-paren' rule with '@typescript-eslint' version
188
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/space-before-function-paren.md
189
- "space-before-function-paren": "off",
190
- "@typescript-eslint/space-before-function-paren": baseStyleRules["space-before-function-paren"],
191
-
192
- // Replace 'require-await' rule with '@typescript-eslint' version
193
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/require-await.md
194
- "require-await": "off",
195
- "@typescript-eslint/require-await": baseBestPracticesRules["require-await"],
196
-
197
- // Replace 'no-return-await' rule with '@typescript-eslint' version
198
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/return-await.md
199
- "no-return-await": "off",
200
- "@typescript-eslint/return-await": baseBestPracticesRules["no-return-await"],
201
-
202
- // Replace 'space-infix-ops' rule with '@typescript-eslint' version
203
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/space-infix-ops.md
204
- "space-infix-ops": "off",
205
- "@typescript-eslint/space-infix-ops": baseStyleRules["space-infix-ops"],
206
-
207
- // Append 'ts' and 'tsx' to 'import/extensions' rule
208
- // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
209
- "import/extensions": [
210
- baseImportsRules["import/extensions"][0],
211
- baseImportsRules["import/extensions"][1],
212
- {
213
- ...baseImportsRules["import/extensions"][2],
214
- ts: "never",
215
- tsx: "never",
216
- },
217
- ],
218
-
219
- // Append 'ts' and 'tsx' extensions to 'import/no-extraneous-dependencies' rule
220
- // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
221
- "import/no-extraneous-dependencies": [
222
- baseImportsRules["import/no-extraneous-dependencies"][0],
223
- {
224
- ...baseImportsRules["import/no-extraneous-dependencies"][1],
225
- devDependencies: baseImportsRules["import/no-extraneous-dependencies"][1].devDependencies.map((glob) =>
226
- glob.replace(/\bjs(x?)\b/g, "ts$1"),
227
- ),
228
- },
229
- ],
230
- },
231
9
  overrides: [
232
10
  {
233
11
  files: ["*.ts", "*.tsx"],
12
+ extends: ["plugin:import/typescript"],
13
+ plugins: ["@typescript-eslint"],
14
+ parser: "@typescript-eslint/parser",
15
+ settings: {
16
+ // Apply special parsing for TypeScript files
17
+ "import/parsers": {
18
+ "@typescript-eslint/parser": [".ts", ".tsx", ".d.ts"],
19
+ },
20
+ // Append 'ts' extensions to 'import/resolver' setting
21
+ "import/resolver": {
22
+ node: {
23
+ extensions: [".mjs", ".js", ".json", ".ts", ".d.ts"],
24
+ },
25
+ },
26
+ // Append 'ts' extensions to 'import/extensions' setting
27
+ "import/extensions": [".js", ".mjs", ".jsx", ".ts", ".tsx", ".d.ts"],
28
+ // Resolve type definition packages
29
+ "import/external-module-folders": ["node_modules", "node_modules/@types"],
30
+ },
234
31
  rules: {
32
+ // Replace 'brace-style' rule with '@typescript-eslint' version
33
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/brace-style.md
34
+ "brace-style": "off",
35
+ "@typescript-eslint/brace-style": baseStyleRules["brace-style"],
36
+
37
+ // Replace 'camelcase' rule with '@typescript-eslint/naming-convention'
38
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
39
+ camelcase: "off",
40
+ // eslint-disable-next-line max-len
41
+ // The `@typescript-eslint/naming-convention` rule allows `leadingUnderscore` and `trailingUnderscore` settings. However, the existing `no-underscore-dangle` rule already takes care of this.
42
+ "@typescript-eslint/naming-convention": [
43
+ "error",
44
+ // Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables (23.10)
45
+ {
46
+ selector: "variable",
47
+ format: ["camelCase", "PascalCase", "UPPER_CASE"],
48
+ },
49
+ // Allow camelCase functions (23.2), and PascalCase functions (23.8)
50
+ {
51
+ selector: "function",
52
+ format: ["camelCase", "PascalCase"],
53
+ },
54
+ // eslint-disable-next-line max-len
55
+ // recommends PascalCase for classes (23.3), and although does not make TypeScript recommendations, we are assuming this rule would similarly apply to anything "type like", including interfaces, type aliases, and enums
56
+ {
57
+ selector: "typeLike",
58
+ format: ["PascalCase"],
59
+ },
60
+ ],
61
+
62
+ // Replace 'comma-dangle' rule with '@typescript-eslint' version
63
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/comma-dangle.md
64
+ // The TypeScript version also adds 3 new options, all of which should be set to the same value as the base config
65
+ "comma-dangle": "off",
66
+ "@typescript-eslint/comma-dangle": [
67
+ // eslint-disable-next-line radar/no-duplicate-string
68
+ baseStyleRules["comma-dangle"][0],
69
+ {
70
+ ...baseStyleRules["comma-dangle"][1],
71
+ enums: baseStyleRules["comma-dangle"][1].arrays,
72
+ generics: baseStyleRules["comma-dangle"][1].arrays,
73
+ tuples: baseStyleRules["comma-dangle"][1].arrays,
74
+ },
75
+ ],
76
+
77
+ // Replace 'comma-spacing' rule with '@typescript-eslint' version
78
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/comma-spacing.md
79
+ "comma-spacing": "off",
80
+ "@typescript-eslint/comma-spacing": baseStyleRules["comma-spacing"],
81
+
82
+ // Replace 'dot-notation' rule with '@typescript-eslint' version
83
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/dot-notation.md
84
+ "dot-notation": "off",
85
+ "@typescript-eslint/dot-notation": baseBestPracticesRules["dot-notation"],
86
+
87
+ // Replace 'func-call-spacing' rule with '@typescript-eslint' version
88
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/func-call-spacing.md
89
+ "func-call-spacing": "off",
90
+ "@typescript-eslint/func-call-spacing": baseStyleRules["func-call-spacing"],
91
+
92
+ // Replace 'indent' rule with '@typescript-eslint' version
93
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/indent.md
94
+ indent: "off",
95
+ "@typescript-eslint/indent": baseStyleRules.indent,
96
+
97
+ // Replace 'keyword-spacing' rule with '@typescript-eslint' version
98
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/keyword-spacing.md
99
+ "keyword-spacing": "off",
100
+ "@typescript-eslint/keyword-spacing": baseStyleRules["keyword-spacing"],
101
+
102
+ // Replace 'lines-between-class-members' rule with '@typescript-eslint' version
103
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/lines-between-class-members.md
104
+ "lines-between-class-members": "off",
105
+ "@typescript-eslint/lines-between-class-members": baseStyleRules["lines-between-class-members"],
106
+
107
+ // Replace 'no-array-constructor' rule with '@typescript-eslint' version
108
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-array-constructor.md
109
+ "no-array-constructor": "off",
110
+ "@typescript-eslint/no-array-constructor": baseStyleRules["no-array-constructor"],
111
+
112
+ // Replace 'no-dupe-class-members' rule with '@typescript-eslint' version
113
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-dupe-class-members.md
114
+ "no-dupe-class-members": "off",
115
+ "@typescript-eslint/no-dupe-class-members": baseES6Rules["no-dupe-class-members"],
116
+
117
+ // Replace 'no-empty-function' rule with '@typescript-eslint' version
118
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md
119
+ "no-empty-function": "off",
120
+ "@typescript-eslint/no-empty-function": baseBestPracticesRules["no-empty-function"],
121
+
122
+ // Replace 'no-extra-parens' rule with '@typescript-eslint' version
123
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extra-parens.md
124
+ "no-extra-parens": "off",
125
+ "@typescript-eslint/no-extra-parens": baseErrorsRules["no-extra-parens"],
126
+
127
+ // Replace 'no-extra-semi' rule with '@typescript-eslint' version
128
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extra-semi.md
129
+ "no-extra-semi": "off",
130
+ "@typescript-eslint/no-extra-semi": baseErrorsRules["no-extra-semi"],
131
+
132
+ // Replace 'no-implied-eval' and 'no-new-func' rules with '@typescript-eslint' version
133
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-implied-eval.md
134
+ "no-implied-eval": "off",
135
+ "no-new-func": "off",
136
+ "@typescript-eslint/no-implied-eval": baseBestPracticesRules["no-implied-eval"],
137
+
138
+ // Replace 'no-loop-func' rule with '@typescript-eslint' version
139
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-loop-func.md
140
+ "no-loop-func": "off",
141
+ "@typescript-eslint/no-loop-func": baseBestPracticesRules["no-loop-func"],
142
+
143
+ // Replace 'no-magic-numbers' rule with '@typescript-eslint' version
144
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-magic-numbers.md
145
+ "no-magic-numbers": "off",
146
+ "@typescript-eslint/no-magic-numbers": baseBestPracticesRules["no-magic-numbers"],
147
+
148
+ // Replace 'no-redeclare' rule with '@typescript-eslint' version
149
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-redeclare.md
150
+ "no-redeclare": "off",
151
+ "@typescript-eslint/no-redeclare": baseBestPracticesRules["no-redeclare"],
152
+
153
+ // Replace 'no-shadow' rule with '@typescript-eslint' version
154
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-shadow.md
155
+ "no-shadow": "off",
156
+ "@typescript-eslint/no-shadow": baseVariablesRules["no-shadow"],
157
+
158
+ // Replace 'no-throw-literal' rule with '@typescript-eslint' version
159
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-throw-literal.md
160
+ "no-throw-literal": "off",
161
+ "@typescript-eslint/no-throw-literal": baseBestPracticesRules["no-throw-literal"],
162
+
163
+ // Replace 'no-unused-expressions' rule with '@typescript-eslint' version
164
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-expressions.md
165
+ "no-unused-expressions": "off",
166
+ "@typescript-eslint/no-unused-expressions": baseBestPracticesRules["no-unused-expressions"],
167
+
168
+ // Replace 'no-unused-vars' rule with '@typescript-eslint' version
169
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
170
+ "no-unused-vars": "off",
171
+ "@typescript-eslint/no-unused-vars": baseVariablesRules["no-unused-vars"],
172
+
173
+ // Replace 'no-use-before-define' rule with '@typescript-eslint' version
174
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
175
+ "no-use-before-define": "off",
176
+ "@typescript-eslint/no-use-before-define": baseVariablesRules["no-use-before-define"],
177
+
178
+ // Replace 'no-useless-constructor' rule with '@typescript-eslint' version
179
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-useless-constructor.md
180
+ "no-useless-constructor": "off",
181
+ "@typescript-eslint/no-useless-constructor": baseES6Rules["no-useless-constructor"],
182
+
183
+ // Replace 'quotes' rule with '@typescript-eslint' version
184
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/quotes.md
185
+ quotes: "off",
186
+ "@typescript-eslint/quotes": baseStyleRules.quotes,
187
+
188
+ // Replace 'semi' rule with '@typescript-eslint' version
189
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/semi.md
190
+ semi: "off",
191
+ "@typescript-eslint/semi": baseStyleRules.semi,
192
+
193
+ // Replace 'space-before-function-paren' rule with '@typescript-eslint' version
194
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/space-before-function-paren.md
195
+ "space-before-function-paren": "off",
196
+ "@typescript-eslint/space-before-function-paren": baseStyleRules["space-before-function-paren"],
197
+
198
+ // Replace 'require-await' rule with '@typescript-eslint' version
199
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/require-await.md
200
+ "require-await": "off",
201
+ "@typescript-eslint/require-await": baseBestPracticesRules["require-await"],
202
+
203
+ // Replace 'no-return-await' rule with '@typescript-eslint' version
204
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/return-await.md
205
+ "no-return-await": "off",
206
+ "@typescript-eslint/return-await": baseBestPracticesRules["no-return-await"],
207
+
208
+ // Replace 'space-infix-ops' rule with '@typescript-eslint' version
209
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/space-infix-ops.md
210
+ "space-infix-ops": "off",
211
+ "@typescript-eslint/space-infix-ops": baseStyleRules["space-infix-ops"],
212
+
213
+ // Append 'ts' and 'tsx' to 'import/extensions' rule
214
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
215
+ "import/extensions": [
216
+ // eslint-disable-next-line radar/no-duplicate-string
217
+ baseImportsRules["import/extensions"][0],
218
+ baseImportsRules["import/extensions"][1],
219
+ {
220
+ ...baseImportsRules["import/extensions"][2],
221
+ ts: "never",
222
+ tsx: "never",
223
+ },
224
+ ],
225
+
226
+ // Append 'ts' and 'tsx' extensions to 'import/no-extraneous-dependencies' rule
227
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
228
+ "import/no-extraneous-dependencies": [
229
+ // eslint-disable-next-line radar/no-duplicate-string
230
+ baseImportsRules["import/no-extraneous-dependencies"][0],
231
+ {
232
+ ...baseImportsRules["import/no-extraneous-dependencies"][1],
233
+ devDependencies: baseImportsRules["import/no-extraneous-dependencies"][1].devDependencies.map(
234
+ (glob) => glob.replace(/\bjs(x?)\b/g, "ts$1"),
235
+ ),
236
+ },
237
+ ],
238
+
235
239
  // The following rules are enabled in config, but are already checked (more thoroughly) by the TypeScript compiler
236
240
  // Some of the rules also fail in TypeScript files, for example: https://github.com/typescript-eslint/typescript-eslint/issues/662#issuecomment-507081586
237
241
  "constructor-super": "off",
238
242
  "getter-return": "off",
239
243
  "no-const-assign": "off",
240
244
  "no-dupe-args": "off",
241
- "no-dupe-class-members": "off",
242
245
  "no-dupe-keys": "off",
243
246
  "no-func-assign": "off",
244
247
  "no-new-symbol": "off",
245
248
  "no-obj-calls": "off",
246
- "no-redeclare": "off",
247
249
  "no-this-before-super": "off",
248
250
  "no-undef": "off",
249
251
  "no-unreachable": "off",
@@ -4,6 +4,7 @@ module.exports = {
4
4
  plugins: ["unicorn"],
5
5
  extends: ["plugin:unicorn/recommended"],
6
6
  rules: {
7
+ // eslint-disable-next-line no-undef
7
8
  "unicorn/prefer-node-protocol": semver.gte(process.version, "v16.0.0") ? "error" : "off",
8
9
  "unicorn/template-indent": [
9
10
  "warn",
@@ -14,5 +15,6 @@ module.exports = {
14
15
  comments: ["HTML", "indent"],
15
16
  },
16
17
  ],
18
+ "unicorn/no-array-for-each": "off",
17
19
  },
18
20
  };
package/rules/style.cjs CHANGED
@@ -46,6 +46,7 @@ module.exports = {
46
46
  "comma-dangle": [
47
47
  "error",
48
48
  {
49
+ // eslint-disable-next-line radar/no-duplicate-string
49
50
  arrays: "always-multiline",
50
51
  objects: "always-multiline",
51
52
  imports: "always-multiline",
@@ -252,7 +253,7 @@ module.exports = {
252
253
  // https://eslint.org/docs/rules/max-len
253
254
  "max-len": [
254
255
  "error",
255
- 120,
256
+ 160,
256
257
  2,
257
258
  {
258
259
  ignoreUrls: true,
@@ -369,6 +370,7 @@ module.exports = {
369
370
  ["&", "|", "<<", ">>", ">>>"],
370
371
  ["==", "!=", "===", "!=="],
371
372
  ["&&", "||"],
373
+ ["in", "instanceof"],
372
374
  ],
373
375
  allowSamePrecedence: false,
374
376
  },
@@ -26,7 +26,8 @@ module.exports = {
26
26
  name: "isNaN",
27
27
  message: "Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan",
28
28
  },
29
- ].concat(confusingBrowserGlobals),
29
+ ...confusingBrowserGlobals,
30
+ ],
30
31
 
31
32
  // disallow declaration of variables already declared in the outer scope
32
33
  "no-shadow": "error",
@@ -40,9 +41,9 @@ module.exports = {
40
41
  // disallow use of undefined when initializing variables
41
42
  "no-undef-init": "error",
42
43
 
43
- // disallow use of undefined variable
44
+ // allow use of undefined variable
44
45
  // https://eslint.org/docs/rules/no-undefined
45
- "no-undefined": "error",
46
+ "no-undefined": "off",
46
47
 
47
48
  // disallow declaration of variables that are not used in the code
48
49
  "no-unused-vars": ["error", { vars: "all", args: "after-used", ignoreRestSiblings: true }],