@perfective/eslint-config 0.21.0-beta.1 → 0.21.0-beta.3

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.
@@ -0,0 +1 @@
1
+ export declare function hasNodeModule(module: string): boolean;
@@ -0,0 +1,5 @@
1
+ export declare function optionalConfig(plugin: string, rules: Record<string, unknown>): Record<string, unknown>;
2
+ export declare function optionalOverrides(plugin: string, overrides: Record<string, unknown>): Record<string, unknown> | null;
3
+ export declare function optionalRules(plugin: string): string | null;
4
+ export declare function optionalRule(rule: string, config: unknown): Record<string, unknown>;
5
+ export declare function hasEslintPlugin(plugin: string): boolean;
package/config/plugin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasEslintPlugin = exports.optionalRules = exports.optionalOverrides = exports.optionalConfig = void 0;
3
+ exports.hasEslintPlugin = exports.optionalRule = exports.optionalRules = exports.optionalOverrides = exports.optionalConfig = void 0;
4
4
  const node_1 = require("./node");
5
5
  function optionalConfig(plugin, rules) {
6
6
  if (hasEslintPlugin(plugin)) {
@@ -26,6 +26,19 @@ function optionalRules(plugin) {
26
26
  return null;
27
27
  }
28
28
  exports.optionalRules = optionalRules;
29
+ function optionalRule(rule, config) {
30
+ const plugin = pluginOfRule(rule);
31
+ if (plugin === null) {
32
+ return {};
33
+ }
34
+ if (hasEslintPlugin(plugin)) {
35
+ return {
36
+ [rule]: config,
37
+ };
38
+ }
39
+ return {};
40
+ }
41
+ exports.optionalRule = optionalRule;
29
42
  function hasEslintPlugin(plugin) {
30
43
  if (plugin.startsWith('@')) {
31
44
  return (0, node_1.hasNodeModule)(`${plugin}/eslint-plugin`);
@@ -33,3 +46,10 @@ function hasEslintPlugin(plugin) {
33
46
  return (0, node_1.hasNodeModule)(`eslint-plugin-${plugin}`);
34
47
  }
35
48
  exports.hasEslintPlugin = hasEslintPlugin;
49
+ function pluginOfRule(rule) {
50
+ const parts = rule.split('/');
51
+ if (parts.length > 1) {
52
+ return parts[0];
53
+ }
54
+ return null;
55
+ }
package/config.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { hasEslintPlugin, optionalConfig, optionalOverrides, optionalRule, optionalRules, } from './config/plugin';
package/config.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.optionalRules = exports.optionalRule = exports.optionalOverrides = exports.optionalConfig = exports.hasEslintPlugin = void 0;
4
+ var plugin_1 = require("./config/plugin");
5
+ Object.defineProperty(exports, "hasEslintPlugin", { enumerable: true, get: function () { return plugin_1.hasEslintPlugin; } });
6
+ Object.defineProperty(exports, "optionalConfig", { enumerable: true, get: function () { return plugin_1.optionalConfig; } });
7
+ Object.defineProperty(exports, "optionalOverrides", { enumerable: true, get: function () { return plugin_1.optionalOverrides; } });
8
+ Object.defineProperty(exports, "optionalRule", { enumerable: true, get: function () { return plugin_1.optionalRule; } });
9
+ Object.defineProperty(exports, "optionalRules", { enumerable: true, get: function () { return plugin_1.optionalRules; } });
package/index.js CHANGED
@@ -43,6 +43,7 @@ module.exports = {
43
43
  'import/no-extraneous-dependencies': ['error', (0, no_extraneous_dependencies_1.jsImportNoExtraneousDependencies)()],
44
44
  'import/unambiguous': 'off',
45
45
  'jsdoc/no-types': 'off',
46
+ 'jsdoc/no-undefined-types': 'off',
46
47
  'jsdoc/require-param': 'error',
47
48
  'jsdoc/require-param-type': 'error',
48
49
  'jsdoc/require-returns': 'error',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perfective/eslint-config",
3
- "version": "0.21.0-beta.1",
3
+ "version": "0.21.0-beta.3",
4
4
  "description": "ESLint shareable rules configuration",
5
5
  "keywords": ["code quality", "code standard", "code style", "eslint", "eslint config", "lint", "perfective", "tslint", "tslint config", "typescript"],
6
6
  "author": "Andrey Mikheychik <a.mikheychik@gmail.com>",
@@ -11,21 +11,21 @@
11
11
  },
12
12
  "license": "MIT",
13
13
  "peerDependencies": {
14
- "@babel/eslint-parser": "^7.21.8",
15
- "@typescript-eslint/eslint-plugin": "^5.59.5",
16
- "@typescript-eslint/eslint-plugin-tslint": "^5.59.5",
17
- "@typescript-eslint/parser": "^5.59.5",
18
- "eslint": "^8.40.0",
14
+ "@babel/eslint-parser": "^7.22.9",
15
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
16
+ "@typescript-eslint/eslint-plugin-tslint": "^5.62.0",
17
+ "@typescript-eslint/parser": "^5.62.0",
18
+ "eslint": "^8.46.0",
19
19
  "eslint-import-resolver-typescript": "^3.5.5",
20
20
  "eslint-plugin-array-func": "^3.1.8",
21
21
  "eslint-plugin-cypress": "^2.13.3",
22
- "eslint-plugin-deprecation": "^1.4.1",
22
+ "eslint-plugin-deprecation": "^1.5.0",
23
23
  "eslint-plugin-eslint-comments": "^3.2.0",
24
- "eslint-plugin-import": "^2.27.5",
25
- "eslint-plugin-jest": "^27.2.1",
24
+ "eslint-plugin-import": "^2.28.0",
25
+ "eslint-plugin-jest": "^27.2.3",
26
26
  "eslint-plugin-jest-dom": "^4.0.3",
27
27
  "eslint-plugin-jest-formatting": "^3.1.0",
28
- "eslint-plugin-jsdoc": "^44.2.3",
28
+ "eslint-plugin-jsdoc": "^46.4.5",
29
29
  "eslint-plugin-node": "^11.1.0",
30
30
  "eslint-plugin-prefer-arrow": "^1.2.3",
31
31
  "eslint-plugin-promise": "^6.1.1",
@@ -33,7 +33,7 @@
33
33
  "eslint-plugin-simple-import-sort": "^10.0.0",
34
34
  "eslint-plugin-sonarjs": "^0.19.0",
35
35
  "eslint-plugin-testing-library": "^5.11.0",
36
- "eslint-plugin-unicorn": "^47.0.0",
36
+ "eslint-plugin-unicorn": "^48.0.1",
37
37
  "tslint": "^6.1.3"
38
38
  },
39
39
  "peerDependenciesMeta": {
@@ -63,5 +63,18 @@
63
63
  "directories": {
64
64
  "lib": "./"
65
65
  },
66
- "files": ["**/*.js", "rules.d.ts", "rules/**/rules/*.d.ts"]
66
+ "files": ["**/*.js", "config.d.ts", "config/**/*.d.ts", "rules.d.ts", "rules/**/rules/*.d.ts"],
67
+ "exports": {
68
+ ".": {
69
+ "require": "./index.js"
70
+ },
71
+ "./config": {
72
+ "require": "./config.js",
73
+ "types": "./config.d.ts"
74
+ },
75
+ "./rules": {
76
+ "require": "./rules.js",
77
+ "types": "./rules.d.ts"
78
+ }
79
+ }
67
80
  }
@@ -90,6 +90,7 @@ module.exports = {
90
90
  ignoreJSX: 'all',
91
91
  nestedBinaryExpressions: false,
92
92
  enforceForArrowConditionals: false,
93
+ ternaryOperandBinaryExpressions: false,
93
94
  }],
94
95
  'no-mixed-spaces-and-tabs': 'error',
95
96
  'no-multi-spaces': 'warn',
@@ -34,7 +34,13 @@ module.exports = {
34
34
  'no-import-assign': 'error',
35
35
  'no-inner-declarations': 'error',
36
36
  'no-invalid-regexp': 'error',
37
- 'no-irregular-whitespace': 'error',
37
+ 'no-irregular-whitespace': ['error', {
38
+ skipStrings: false,
39
+ skipComments: false,
40
+ skipRegExps: false,
41
+ skipTemplates: false,
42
+ skipJSXText: false,
43
+ }],
38
44
  'no-loss-of-precision': 'error',
39
45
  'no-misleading-character-class': 'error',
40
46
  'no-new-native-nonconstructor': 'error',
@@ -127,7 +127,7 @@ module.exports = {
127
127
  'no-restricted-properties': 'error',
128
128
  'no-restricted-syntax': ['error', 'ForInStatement'],
129
129
  'no-return-assign': 'error',
130
- 'no-return-await': 'error',
130
+ 'no-return-await': 'off',
131
131
  'no-script-url': 'error',
132
132
  'no-sequences': ['error', {
133
133
  allowInParentheses: false,
@@ -53,6 +53,7 @@ module.exports = {
53
53
  tags: ['final', 'flags', 'sealed'],
54
54
  }],
55
55
  'jsdoc/implements-on-classes': 'error',
56
+ 'jsdoc/imports-as-dependencies': 'error',
56
57
  'jsdoc/match-description': 'error',
57
58
  'jsdoc/match-name': 'off',
58
59
  'jsdoc/multiline-blocks': ['error', {
@@ -206,6 +206,12 @@ module.exports = {
206
206
  ignoreTernaryTests: false,
207
207
  ignoreConditionalTests: true,
208
208
  ignoreMixedLogicalExpressions: true,
209
+ ignorePrimitives: {
210
+ bigint: false,
211
+ boolean: false,
212
+ number: false,
213
+ string: false,
214
+ },
209
215
  }],
210
216
  '@typescript-eslint/prefer-optional-chain': 'error',
211
217
  '@typescript-eslint/prefer-readonly': 'warn',
@@ -222,8 +228,12 @@ module.exports = {
222
228
  ignoreStringArrays: true,
223
229
  }],
224
230
  '@typescript-eslint/restrict-plus-operands': ['error', {
225
- checkCompoundAssignments: true,
226
231
  allowAny: false,
232
+ allowBoolean: false,
233
+ allowNullish: false,
234
+ allowNumberAndString: false,
235
+ allowRegExp: false,
236
+ checkCompoundAssignments: true,
227
237
  }],
228
238
  '@typescript-eslint/restrict-template-expressions': ['error', {
229
239
  allowAny: false,
@@ -61,7 +61,7 @@ module.exports = {
61
61
  'unicorn/no-unnecessary-await': 'warn',
62
62
  'unicorn/no-unreadable-array-destructuring': 'error',
63
63
  'unicorn/no-unreadable-iife': 'error',
64
- 'unicorn/no-unsafe-regex': 'error',
64
+ 'unicorn/no-unsafe-regex': 'off',
65
65
  'unicorn/no-unused-properties': 'off',
66
66
  'unicorn/no-useless-fallback-in-spread': 'warn',
67
67
  'unicorn/no-useless-length-check': 'warn',