@perfective/eslint-config 0.25.1 → 0.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2020-2022 Andrey Mikheychik (https://github.com/amikheychik)
3
+ Copyright (c) 2020-2024 Andrey Mikheychik (https://github.com/amikheychik)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.adoc CHANGED
@@ -20,10 +20,11 @@ and https://eslint.style[ESLint Stylistic] plugin rules,
20
20
  * `link:https://github.com/dangreenisrael/eslint-plugin-jest-formatting[eslint-plugin-jest-formatting]`
21
21
  _(optional, required if `eslint-plugin-jest` is installed)_;
22
22
  * `link:https://github.com/gajus/eslint-plugin-jsdoc[eslint-plugin-jsdoc]`;
23
- * `link:https://github.com/mysticatea/eslint-plugin-node[eslint-plugin-node]`;
23
+ * `link:https://github.com/eslint-community/eslint-plugin-n[eslint-plugin-n]`;
24
24
  * `link:https://github.com/TristonJ/eslint-plugin-prefer-arrow[eslint-plugin-prefer-arrow]`;
25
25
  * `link:https://github.com/eslint-community/eslint-plugin-promise[eslint-plugin-promise]`;
26
26
  * `link:https://github.com/cartant/eslint-plugin-rxjs[eslint-plugin-rxjs]` _(optional)_;
27
+ * `link:https://github.com/eslint-community/eslint-plugin-security[eslint-plugin-security]`;
27
28
  * `link:https://github.com/lydell/eslint-plugin-simple-import-sort[eslint-plugin-simple-import-sort]`;
28
29
  * `link:https://github.com/SonarSource/eslint-plugin-sonarjs[eslint-plugin-sonarjs]`;
29
30
  * `link:https://github.com/testing-library/eslint-plugin-testing-library[eslint-plugin-testing-library]` _(optional)_;
@@ -55,9 +56,10 @@ npm install --save-dev \
55
56
  eslint-plugin-eslint-comments \
56
57
  eslint-plugin-import \
57
58
  eslint-plugin-jsdoc \
58
- eslint-plugin-node \
59
+ eslint-plugin-n \
59
60
  eslint-plugin-prefer-arrow \
60
61
  eslint-plugin-promise \
62
+ eslint-plugin-security \
61
63
  eslint-plugin-simple-import-sort \
62
64
  eslint-plugin-sonarjs \
63
65
  eslint-plugin-unicorn \
package/README.md CHANGED
@@ -20,10 +20,11 @@ and [ESlint Stylistic](https://eslint.style) plugin rules,
20
20
  - [`eslint-plugin-jest-formatting`](https://github.com/dangreenisrael/eslint-plugin-jest-formatting)
21
21
  _(optional, required if `eslint-plugin-jest` is installed)_;
22
22
  - [`eslint-plugin-jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc);
23
- - [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node);
23
+ - [`eslint-plugin-n`](https://github.com/eslint-community/eslint-plugin-n);
24
24
  - [`eslint-plugin-prefer-arrow`](https://github.com/TristonJ/eslint-plugin-prefer-arrow);
25
25
  - [`eslint-plugin-promise`](https://github.com/eslint-community/eslint-plugin-promise);
26
26
  - [`eslint-plugin-rxjs`](https://github.com/cartant/eslint-plugin-rxjs) _(optional)_;
27
+ - [`eslint-plugin-security`](https://github.com/eslint-community/eslint-plugin-security);
27
28
  - [`eslint-plugin-simple-import-sort`](https://github.com/lydell/eslint-plugin-simple-import-sort);
28
29
  - [`eslint-plugin-sonarjs`](https://github.com/SonarSource/eslint-plugin-sonarjs);
29
30
  - [`eslint-plugin-testing-library`](https://github.com/testing-library/eslint-plugin-testing-library) _(optional)_;
@@ -53,9 +54,10 @@ from issues that will be fixed automatically.
53
54
  eslint-plugin-eslint-comments \
54
55
  eslint-plugin-import \
55
56
  eslint-plugin-jsdoc \
56
- eslint-plugin-node \
57
+ eslint-plugin-n \
57
58
  eslint-plugin-prefer-arrow \
58
59
  eslint-plugin-promise \
60
+ eslint-plugin-security \
59
61
  eslint-plugin-simple-import-sort \
60
62
  eslint-plugin-sonarjs \
61
63
  eslint-plugin-unicorn \
package/config/node.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasNodeModule = void 0;
3
+ exports.hasNodeModule = hasNodeModule;
4
4
  function hasNodeModule(module) {
5
5
  try {
6
6
  return Boolean(require.resolve(module));
@@ -9,4 +9,3 @@ function hasNodeModule(module) {
9
9
  return false;
10
10
  }
11
11
  }
12
- exports.hasNodeModule = hasNodeModule;
package/config/plugin.js CHANGED
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasEslintPlugin = exports.optionalRule = exports.optionalRules = exports.optionalOverrides = exports.optionalConfig = void 0;
3
+ exports.optionalConfig = optionalConfig;
4
+ exports.optionalOverrides = optionalOverrides;
5
+ exports.optionalRules = optionalRules;
6
+ exports.optionalRule = optionalRule;
7
+ exports.hasEslintPlugin = hasEslintPlugin;
4
8
  const node_1 = require("./node");
5
9
  function optionalConfig(plugin, rules) {
6
10
  if (hasEslintPlugin(plugin)) {
@@ -11,21 +15,18 @@ function optionalConfig(plugin, rules) {
11
15
  }
12
16
  return {};
13
17
  }
14
- exports.optionalConfig = optionalConfig;
15
18
  function optionalOverrides(plugin, overrides) {
16
19
  if (hasEslintPlugin(plugin)) {
17
20
  return overrides;
18
21
  }
19
22
  return null;
20
23
  }
21
- exports.optionalOverrides = optionalOverrides;
22
24
  function optionalRules(plugin) {
23
25
  if (hasEslintPlugin(plugin)) {
24
26
  return `./rules/${plugin.replace(/^@/u, '')}`;
25
27
  }
26
28
  return null;
27
29
  }
28
- exports.optionalRules = optionalRules;
29
30
  function optionalRule(rule, config) {
30
31
  const plugin = pluginOfRule(rule);
31
32
  if (plugin === null) {
@@ -38,14 +39,12 @@ function optionalRule(rule, config) {
38
39
  }
39
40
  return {};
40
41
  }
41
- exports.optionalRule = optionalRule;
42
42
  function hasEslintPlugin(plugin) {
43
43
  if (plugin.startsWith('@')) {
44
44
  return (0, node_1.hasNodeModule)(`${plugin}/eslint-plugin`);
45
45
  }
46
46
  return (0, node_1.hasNodeModule)(`eslint-plugin-${plugin}`);
47
47
  }
48
- exports.hasEslintPlugin = hasEslintPlugin;
49
48
  function pluginOfRule(rule) {
50
49
  const parts = rule.split('/');
51
50
  if (parts.length > 1) {
package/index.js CHANGED
@@ -16,9 +16,9 @@ module.exports = {
16
16
  './rules/import',
17
17
  './rules/jsdoc',
18
18
  './rules/n',
19
- './rules/node',
20
19
  './rules/prefer-arrow',
21
20
  './rules/promise',
21
+ './rules/security',
22
22
  './rules/simple-import-sort',
23
23
  './rules/sonarjs',
24
24
  './rules/stylistic/js',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perfective/eslint-config",
3
- "version": "0.25.1",
3
+ "version": "0.26.1",
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>",
@@ -12,10 +12,10 @@
12
12
  "license": "MIT",
13
13
  "peerDependencies": {
14
14
  "@babel/eslint-parser": "^7.24.7",
15
- "@stylistic/eslint-plugin": "^2.1.0",
16
- "@typescript-eslint/eslint-plugin": "^7.12.0",
15
+ "@stylistic/eslint-plugin": "^2.3.0",
16
+ "@typescript-eslint/eslint-plugin": "^7.14.1",
17
17
  "@typescript-eslint/eslint-plugin-tslint": "^7.0.2",
18
- "@typescript-eslint/parser": "^7.12.0",
18
+ "@typescript-eslint/parser": "^7.14.1",
19
19
  "eslint": "^8.57.0",
20
20
  "eslint-import-resolver-typescript": "^3.6.1",
21
21
  "eslint-plugin-array-func": "^4.0.0",
@@ -26,16 +26,16 @@
26
26
  "eslint-plugin-jest": "^28.6.0",
27
27
  "eslint-plugin-jest-dom": "^5.4.0",
28
28
  "eslint-plugin-jest-formatting": "^3.1.0",
29
- "eslint-plugin-jsdoc": "^48.2.9",
30
- "eslint-plugin-n": "^17.8.1",
31
- "eslint-plugin-node": "^11.1.0",
29
+ "eslint-plugin-jsdoc": "^48.5.0",
30
+ "eslint-plugin-n": "^17.9.0",
32
31
  "eslint-plugin-prefer-arrow": "^1.2.3",
33
32
  "eslint-plugin-promise": "^6.2.0",
34
33
  "eslint-plugin-rxjs": "^5.0.3",
34
+ "eslint-plugin-security": "^3.0.1",
35
35
  "eslint-plugin-simple-import-sort": "^12.1.0",
36
36
  "eslint-plugin-sonarjs": "^1.0.3",
37
37
  "eslint-plugin-testing-library": "^6.2.2",
38
- "eslint-plugin-unicorn": "^53.0.0",
38
+ "eslint-plugin-unicorn": "^54.0.0",
39
39
  "tslint": "^6.1.3"
40
40
  },
41
41
  "peerDependenciesMeta": {
@@ -1,25 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cypressImportNoExtraneousDependencies = exports.jestImportNoExtraneousDependencies = exports.jsImportNoExtraneousDependencies = exports.importNoExtraneousDependencies = void 0;
3
+ exports.importNoExtraneousDependencies = importNoExtraneousDependencies;
4
+ exports.jsImportNoExtraneousDependencies = jsImportNoExtraneousDependencies;
5
+ exports.jestImportNoExtraneousDependencies = jestImportNoExtraneousDependencies;
6
+ exports.cypressImportNoExtraneousDependencies = cypressImportNoExtraneousDependencies;
4
7
  function importNoExtraneousDependencies(overrides = {}) {
5
8
  return Object.assign({ bundledDependencies: true, devDependencies: false, optionalDependencies: false, peerDependencies: false }, overrides);
6
9
  }
7
- exports.importNoExtraneousDependencies = importNoExtraneousDependencies;
8
10
  function jsImportNoExtraneousDependencies(devDependencies = ['**/.*.js', '**/*.config.js', '**/gulpfile.js']) {
9
11
  return importNoExtraneousDependencies({
10
12
  devDependencies,
11
13
  });
12
14
  }
13
- exports.jsImportNoExtraneousDependencies = jsImportNoExtraneousDependencies;
14
15
  function jestImportNoExtraneousDependencies(devDependencies = ['**/*.@(spec|test).[jt]s?(x)']) {
15
16
  return importNoExtraneousDependencies({
16
17
  devDependencies,
17
18
  });
18
19
  }
19
- exports.jestImportNoExtraneousDependencies = jestImportNoExtraneousDependencies;
20
20
  function cypressImportNoExtraneousDependencies(devDependencies = ['cypress/**/*.[jt]s']) {
21
21
  return importNoExtraneousDependencies({
22
22
  devDependencies,
23
23
  });
24
24
  }
25
- exports.cypressImportNoExtraneousDependencies = cypressImportNoExtraneousDependencies;
package/rules/n/index.js CHANGED
@@ -29,9 +29,12 @@ module.exports = {
29
29
  allowAtRootLevel: false,
30
30
  }],
31
31
  'n/no-unpublished-bin': 'error',
32
- 'n/no-unpublished-import': 'error',
32
+ 'n/no-unpublished-import': ['error', {
33
+ ignorePrivate: false,
34
+ }],
33
35
  'n/no-unpublished-require': ['error', {
34
36
  allowModules: [],
37
+ ignorePrivate: false,
35
38
  tryExtensions: ['.js', '.json', '.node'],
36
39
  }],
37
40
  'n/no-unsupported-features/es-builtins': ['error', {
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ module.exports = {
3
+ plugins: [
4
+ 'security',
5
+ ],
6
+ rules: {
7
+ 'security/detect-bidi-characters': 'error',
8
+ 'security/detect-buffer-noassert': 'error',
9
+ 'security/detect-child-process': 'error',
10
+ 'security/detect-disable-mustache-escape': 'error',
11
+ 'security/detect-eval-with-expression': 'error',
12
+ 'security/detect-new-buffer': 'error',
13
+ 'security/detect-no-csrf-before-method-override': 'error',
14
+ 'security/detect-non-literal-fs-filename': 'error',
15
+ 'security/detect-non-literal-regexp': 'error',
16
+ 'security/detect-non-literal-require': 'error',
17
+ 'security/detect-object-injection': 'error',
18
+ 'security/detect-possible-timing-attacks': 'error',
19
+ 'security/detect-pseudoRandomBytes': 'error',
20
+ 'security/detect-unsafe-regex': 'error',
21
+ },
22
+ };
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.internalPackages = exports.scopedPackages = exports.simpleImportSortImports = void 0;
3
+ exports.simpleImportSortImports = simpleImportSortImports;
4
+ exports.scopedPackages = scopedPackages;
5
+ exports.internalPackages = internalPackages;
4
6
  function simpleImportSortImports(internal = []) {
5
7
  return {
6
8
  groups: [
@@ -15,7 +17,6 @@ function simpleImportSortImports(internal = []) {
15
17
  ].filter(group => group.length > 0),
16
18
  };
17
19
  }
18
- exports.simpleImportSortImports = simpleImportSortImports;
19
20
  function sideEffects() {
20
21
  return ['^\\u0000'];
21
22
  }
@@ -31,11 +32,9 @@ function scopedPackages(exclude) {
31
32
  }
32
33
  return [`^(?!${exclude.join('|')})@`];
33
34
  }
34
- exports.scopedPackages = scopedPackages;
35
35
  function internalPackages(internal) {
36
36
  return internal.map(scope => [`^${scope}`]);
37
37
  }
38
- exports.internalPackages = internalPackages;
39
38
  function parentImports() {
40
39
  return ['^\\.\\.(?!/?$)', '^\\.\\./?$'];
41
40
  }
@@ -156,6 +156,7 @@ module.exports = {
156
156
  '@stylistic/js/quotes': ['warn', 'single', {
157
157
  avoidEscape: true,
158
158
  allowTemplateLiterals: true,
159
+ ignoreStringLiterals: false,
159
160
  }],
160
161
  '@stylistic/js/rest-spread-spacing': ['warn', 'never'],
161
162
  '@stylistic/js/semi': ['warn', 'always'],
@@ -28,10 +28,7 @@ module.exports = {
28
28
  '@stylistic/jsx/jsx-equals-spacing': ['warn', 'never'],
29
29
  '@stylistic/jsx/jsx-first-prop-new-line': ['warn', 'multiline-multiprop'],
30
30
  '@stylistic/jsx/jsx-function-call-newline': ['warn', 'multiline'],
31
- '@stylistic/jsx/jsx-indent': ['warn', 4, {
32
- checkAttributes: true,
33
- indentLogicalExpressions: true,
34
- }],
31
+ '@stylistic/jsx/jsx-indent': 'off',
35
32
  '@stylistic/jsx/jsx-indent-props': ['warn', {
36
33
  indentMode: 1,
37
34
  ignoreTernaryOperator: false,
@@ -91,11 +91,20 @@ module.exports = {
91
91
  }],
92
92
  '@stylistic/js/no-extra-semi': 'off',
93
93
  '@stylistic/ts/no-extra-semi': 'warn',
94
+ '@stylistic/js/object-curly-newline': 'off',
95
+ '@stylistic/ts/object-curly-newline': ['warn', {
96
+ ImportDeclaration: { multiline: true },
97
+ ExportDeclaration: { multiline: true },
98
+ }],
94
99
  '@stylistic/js/object-curly-spacing': 'off',
95
100
  '@stylistic/ts/object-curly-spacing': ['warn', 'always', {
96
101
  arraysInObjects: true,
97
102
  objectsInObjects: true,
98
103
  }],
104
+ '@stylistic/js/object-property-newline': 'off',
105
+ '@stylistic/ts/object-property-newline': ['warn', {
106
+ allowAllPropertiesOnSameLine: true,
107
+ }],
99
108
  '@stylistic/js/padding-line-between-statements': 'off',
100
109
  '@stylistic/ts/padding-line-between-statements': 'off',
101
110
  '@stylistic/js/quote-props': 'off',
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.typescriptEslintNamingConvention = void 0;
3
+ exports.typescriptEslintNamingConvention = typescriptEslintNamingConvention;
4
4
  function typescriptEslintNamingConvention(extensions = []) {
5
5
  return typescriptEslintNamingConventionDefaults()
6
6
  .concat(extensions);
7
7
  }
8
- exports.typescriptEslintNamingConvention = typescriptEslintNamingConvention;
9
8
  function typescriptEslintNamingConventionDefaults() {
10
9
  return [
11
10
  {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.typescriptEslintTslintConfig = void 0;
3
+ exports.typescriptEslintTslintConfig = typescriptEslintTslintConfig;
4
4
  const format = {
5
5
  'import-spacing': true,
6
6
  };
@@ -32,4 +32,3 @@ function typescriptEslintTslintConfig(rules = {}, directories = []) {
32
32
  rulesDirectory: directories,
33
33
  };
34
34
  }
35
- exports.typescriptEslintTslintConfig = typescriptEslintTslintConfig;
@@ -51,6 +51,7 @@ module.exports = {
51
51
  'unicorn/no-lonely-if': 'warn',
52
52
  'unicorn/no-magic-array-flat-depth': 'error',
53
53
  'unicorn/no-negated-condition': 'warn',
54
+ 'unicorn/no-negation-in-equality-check': 'error',
54
55
  'unicorn/no-nested-ternary': 'off',
55
56
  'unicorn/no-new-array': 'warn',
56
57
  'unicorn/no-new-buffer': 'warn',
@@ -97,7 +98,9 @@ module.exports = {
97
98
  },
98
99
  }],
99
100
  'unicorn/prefer-add-event-listener': 'warn',
100
- 'unicorn/prefer-array-find': 'warn',
101
+ 'unicorn/prefer-array-find': ['warn', {
102
+ checkFromLast: true,
103
+ }],
101
104
  'unicorn/prefer-array-flat': 'off',
102
105
  'unicorn/prefer-array-flat-map': 'off',
103
106
  'unicorn/prefer-array-index-of': 'warn',
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unicornPreventAbbreviations = void 0;
3
+ exports.unicornPreventAbbreviations = unicornPreventAbbreviations;
4
4
  function unicornPreventAbbreviations(replacements = {}, options = {}) {
5
5
  return Object.assign(Object.assign({ replacements: Object.assign({ arg: false, args: false, db: false, doc: false, docs: false, dev: false, env: false, i: false, j: false, lib: false, libs: false, param: false, params: false }, replacements), extendDefaultReplacements: true, allowList: {}, extendDefaultAllowList: true, checkDefaultAndNamespaceImports: 'internal', checkShorthandImports: 'internal', checkShorthandProperties: false, checkProperties: false, checkVariables: true, checkFilenames: true }, options), { ignore: [
6
6
  /e2e/u,
7
7
  ] });
8
8
  }
9
- exports.unicornPreventAbbreviations = unicornPreventAbbreviations;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- module.exports = {
3
- rules: {
4
- 'node/no-deprecated-api': 'off',
5
- },
6
- };
@@ -1,11 +0,0 @@
1
- "use strict";
2
- module.exports = {
3
- plugins: [
4
- 'node',
5
- ],
6
- extends: [
7
- './possible-errors',
8
- './best-practices',
9
- './stylistic-issues',
10
- ],
11
- };
@@ -1,23 +0,0 @@
1
- "use strict";
2
- module.exports = {
3
- rules: {
4
- 'node/handle-callback-err': 'off',
5
- 'node/no-callback-literal': 'off',
6
- 'node/no-exports-assign': 'off',
7
- 'node/no-extraneous-import': 'off',
8
- 'node/no-extraneous-require': 'off',
9
- 'node/no-missing-import': 'off',
10
- 'node/no-missing-require': 'off',
11
- 'node/no-new-require': 'off',
12
- 'node/no-path-concat': 'off',
13
- 'node/no-process-exit': 'off',
14
- 'node/no-unpublished-bin': 'off',
15
- 'node/no-unpublished-import': 'off',
16
- 'node/no-unpublished-require': 'off',
17
- 'node/no-unsupported-features/es-builtins': 'off',
18
- 'node/no-unsupported-features/es-syntax': 'off',
19
- 'node/no-unsupported-features/node-builtins': 'off',
20
- 'node/process-exit-as-throw': 'off',
21
- 'node/shebang': 'off',
22
- },
23
- };
@@ -1,23 +0,0 @@
1
- "use strict";
2
- module.exports = {
3
- rules: {
4
- 'node/callback-return': 'off',
5
- 'node/exports-style': ['off', 'module.exports', { allowBatchAssign: false }],
6
- 'node/file-extension-in-import': 'off',
7
- 'node/global-require': 'off',
8
- 'node/no-mixed-requires': 'off',
9
- 'node/no-process-env': 'off',
10
- 'node/no-restricted-import': 'off',
11
- 'node/no-restricted-require': 'off',
12
- 'node/no-sync': 'off',
13
- 'node/prefer-global/buffer': ['off', 'always'],
14
- 'node/prefer-global/console': ['off', 'always'],
15
- 'node/prefer-global/process': ['off', 'always'],
16
- 'node/prefer-global/text-decoder': ['off', 'always'],
17
- 'node/prefer-global/text-encoder': ['off', 'always'],
18
- 'node/prefer-global/url-search-params': ['off', 'always'],
19
- 'node/prefer-global/url': ['off', 'always'],
20
- 'node/prefer-promises/dns': 'off',
21
- 'node/prefer-promises/fs': 'off',
22
- },
23
- };