@open-xchange/linter-presets 0.0.5 → 0.1.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +19 -10
  2. package/README.md +3 -3
  3. package/dist/eslint/config/base.d.ts +16 -0
  4. package/{lib → dist}/eslint/config/base.js +5 -26
  5. package/dist/eslint/config/directives.d.ts +11 -0
  6. package/{lib → dist}/eslint/config/directives.js +1 -5
  7. package/dist/eslint/config/imports.d.ts +15 -0
  8. package/dist/eslint/config/imports.js +58 -0
  9. package/dist/eslint/config/js.d.ts +9 -0
  10. package/dist/eslint/config/js.js +32 -0
  11. package/dist/eslint/config/jsdoc.d.ts +11 -0
  12. package/{lib → dist}/eslint/config/jsdoc.js +1 -9
  13. package/dist/eslint/config/json.d.ts +15 -0
  14. package/{lib → dist}/eslint/config/json.js +2 -8
  15. package/dist/eslint/config/license.d.ts +14 -0
  16. package/{lib → dist}/eslint/config/license.js +12 -18
  17. package/dist/eslint/config/promises.d.ts +11 -0
  18. package/{lib → dist}/eslint/config/promises.js +3 -9
  19. package/dist/eslint/config/stylistic.d.ts +16 -0
  20. package/{lib → dist}/eslint/config/stylistic.js +12 -22
  21. package/dist/eslint/config/ts.d.ts +11 -0
  22. package/{lib → dist}/eslint/config/ts.js +9 -18
  23. package/dist/eslint/config/yaml.d.ts +15 -0
  24. package/{lib → dist}/eslint/config/yaml.js +2 -8
  25. package/dist/eslint/env/browser.d.ts +27 -0
  26. package/{lib → dist}/eslint/env/browser.js +5 -26
  27. package/dist/eslint/env/codecept.d.ts +22 -0
  28. package/{lib → dist}/eslint/env/codecept.js +4 -13
  29. package/dist/eslint/env/eslint.d.ts +20 -0
  30. package/{lib → dist}/eslint/env/eslint.js +2 -9
  31. package/dist/eslint/env/jest.d.ts +21 -0
  32. package/dist/eslint/env/jest.js +49 -0
  33. package/dist/eslint/env/node.d.ts +30 -0
  34. package/{lib → dist}/eslint/env/node.js +2 -14
  35. package/dist/eslint/env/project.d.ts +18 -0
  36. package/{lib → dist}/eslint/env/project.js +18 -25
  37. package/dist/eslint/env/react.d.ts +29 -0
  38. package/{lib → dist}/eslint/env/react.js +3 -15
  39. package/dist/eslint/env/tsconfig.d.ts +21 -0
  40. package/{lib → dist}/eslint/env/tsconfig.js +15 -21
  41. package/dist/eslint/env/vitest.d.ts +23 -0
  42. package/{lib → dist}/eslint/env/vitest.js +3 -16
  43. package/dist/eslint/index.d.ts +63 -0
  44. package/{lib → dist}/eslint/index.js +3 -25
  45. package/dist/eslint/rules/no-amd-module-directive.d.ts +3 -0
  46. package/{lib → dist}/eslint/rules/no-amd-module-directive.js +22 -26
  47. package/dist/eslint/rules/no-invalid-modules.d.ts +38 -0
  48. package/{lib → dist}/eslint/rules/no-invalid-modules.js +41 -64
  49. package/dist/eslint/shared/env-utils.d.ts +150 -0
  50. package/{lib → dist}/eslint/shared/env-utils.js +12 -23
  51. package/dist/eslint/shared/rule-utils.d.ts +76 -0
  52. package/{lib → dist}/eslint/shared/rule-utils.js +27 -60
  53. package/dist/index.d.ts +3 -0
  54. package/{lib → dist}/index.js +0 -1
  55. package/dist/stylelint/index.d.ts +49 -0
  56. package/{lib → dist}/stylelint/index.js +5 -22
  57. package/dist/utils/index.d.ts +12 -0
  58. package/{lib → dist}/utils/index.js +2 -5
  59. package/package.json +12 -4
  60. package/lib/eslint/config/imports.js +0 -68
  61. package/lib/eslint/config/js.js +0 -36
  62. package/lib/eslint/env/browser.d.ts +0 -21
  63. package/lib/eslint/env/codecept.d.ts +0 -14
  64. package/lib/eslint/env/eslint.d.ts +0 -14
  65. package/lib/eslint/env/jest.d.ts +0 -14
  66. package/lib/eslint/env/jest.js +0 -56
  67. package/lib/eslint/env/node.d.ts +0 -28
  68. package/lib/eslint/env/project.d.ts +0 -21
  69. package/lib/eslint/env/react.d.ts +0 -20
  70. package/lib/eslint/env/tsconfig.d.ts +0 -20
  71. package/lib/eslint/env/vitest.d.ts +0 -14
  72. package/lib/eslint/index.d.ts +0 -43
  73. package/lib/eslint/shared/env-utils.d.ts +0 -95
  74. package/lib/eslint/shared/types.d.ts +0 -107
  75. package/lib/index.d.ts +0 -4
  76. package/lib/stylelint/index.d.ts +0 -18
  77. package/lib/stylelint/types.d.ts +0 -44
  78. package/lib/utils/index.d.ts +0 -4
  79. /package/{lib → doc}/eslint/README.md +0 -0
  80. /package/{lib → doc}/eslint/env/browser.md +0 -0
  81. /package/{lib → doc}/eslint/env/codecept.md +0 -0
  82. /package/{lib → doc}/eslint/env/eslint.md +0 -0
  83. /package/{lib → doc}/eslint/env/jest.md +0 -0
  84. /package/{lib → doc}/eslint/env/node.md +0 -0
  85. /package/{lib → doc}/eslint/env/project.md +0 -0
  86. /package/{lib → doc}/eslint/env/react.md +0 -0
  87. /package/{lib → doc}/eslint/env/tsconfig.md +0 -0
  88. /package/{lib → doc}/eslint/env/vitest.md +0 -0
  89. /package/{lib → doc}/stylelint/README.md +0 -0
  90. /package/{lib → doc}/utils/README.md +0 -0
package/CHANGELOG.md CHANGED
@@ -1,13 +1,22 @@
1
1
  # Changelog
2
2
 
3
- ## [0.0.1] - 2024-07-05
3
+ ## [0.1.0] - 2024-07-10
4
4
 
5
- - added: [ESLint] project configuration (core, js, ts, json, yaml, license, directives, promises, jsdoc, stylistic)
6
- - added: [ESLint] environment presets (tsconfig, node, browser, jest, vitest, codecept, react, plugin)
5
+ - chore: converted source code to TypeScript
7
6
 
8
- ## [0.0.2] - 2024-07-08
7
+ ## [0.0.6] - 2024-07-10
9
8
 
10
- - added: [StyleLint] project configuration (core, less, sass, license, stylistic)
9
+ - fixed: [ESLint] type error in `env-project/no-invalid-modules`
10
+
11
+ ## [0.0.5] - 2024-07-10
12
+
13
+ - changed: [ESLint] `env-project/no-invalid-modules`: renamed option `packages.dependsOn` to `packages.extends`
14
+ - chore: [ESLint] documentation for option `restricted`
15
+ - chore: bump dependencies
16
+
17
+ ## [0.0.4] - 2024-07-10
18
+
19
+ - fixed: [ESLint] file exists detection in rule `env-project/no-invalid-modules`
11
20
 
12
21
  ## [0.0.3] - 2024-07-09
13
22
 
@@ -20,11 +29,11 @@
20
29
  - fixed: [StyleLint] support for LESS files
21
30
  - chore: bump dependencies
22
31
 
23
- ## [0.0.4] - 2024-07-10
32
+ ## [0.0.2] - 2024-07-08
24
33
 
25
- - fixed: [ESLint] file exists detection in rule `env-project/no-invalid-modules`
34
+ - added: [StyleLint] project configuration (core, less, sass, license, stylistic)
26
35
 
27
- ## [0.0.5] - 2024-07-10
36
+ ## [0.0.1] - 2024-07-05
28
37
 
29
- - chore: [ESLint] documentation for option `restricted`
30
- - chore: bump dependencies
38
+ - added: [ESLint] project configuration (core, js, ts, json, yaml, license, directives, promises, jsdoc, stylistic)
39
+ - added: [ESLint] environment presets (tsconfig, node, browser, jest, vitest, codecept, react, plugin)
package/README.md CHANGED
@@ -26,7 +26,7 @@ export default [
26
26
  ]
27
27
  ```
28
28
 
29
- See the [`eslint` module documentation](./lib/eslint/README.md) for more details.
29
+ See the [`eslint` module documentation](./doc/eslint/README.md) for more details.
30
30
 
31
31
  ## StyleLint
32
32
 
@@ -43,10 +43,10 @@ export default eslint.configure({
43
43
  })
44
44
  ```
45
45
 
46
- See the [`stylelint` module documentation](./lib/stylelint/README.md) for more details.
46
+ See the [`stylelint` module documentation](./doc/stylelint/README.md) for more details.
47
47
 
48
48
  ## Utils
49
49
 
50
50
  The module `utils` exports utility functions to be used in ESLint and StyleLint configuration files.
51
51
 
52
- See the [`utils` module documentation](./lib/utils/README.md) for more details.
52
+ See the [`utils` module documentation](./doc/utils/README.md) for more details.
@@ -0,0 +1,16 @@
1
+ import type { TSESLint } from "@typescript-eslint/utils";
2
+ import type { LanguageOptions } from "../shared/env-utils.js";
3
+ /**
4
+ * Defines standard module settings and additional rules targeting JavaScript
5
+ * _and_ TypeScript source files.
6
+ *
7
+ * Wraps the following packages:
8
+ * - `@eslint/js`
9
+ *
10
+ * @param options
11
+ * Resolved configuration options.
12
+ *
13
+ * @returns
14
+ * An array of configuration objects to be added to the flat configuration.
15
+ */
16
+ export default function base(options: Required<LanguageOptions>): TSESLint.FlatConfig.ConfigArray;
@@ -1,8 +1,5 @@
1
-
2
1
  import eslintJs from "@eslint/js";
3
-
4
2
  // functions ==================================================================
5
-
6
3
  /**
7
4
  * Defines standard module settings and additional rules targeting JavaScript
8
5
  * _and_ TypeScript source files.
@@ -10,36 +7,22 @@ import eslintJs from "@eslint/js";
10
7
  * Wraps the following packages:
11
8
  * - `@eslint/js`
12
9
  *
13
- * @param {Required<import("../shared/types").LanguageOptions>} options
10
+ * @param options
14
11
  * Resolved configuration options.
15
12
  *
16
- * @returns {import("../shared/types").FlatConfigArray}
13
+ * @returns
17
14
  * An array of configuration objects to be added to the flat configuration.
18
15
  */
19
16
  export default function base(options) {
20
-
21
- /**
22
- * Returns language options for specific file extensions.
23
- *
24
- * @param {"module"|"commonjs"} sourceType
25
- * Module type specifier.
26
- *
27
- * @param {string[]} extensions
28
- * List of file extensions.
29
- *
30
- * @returns {import("eslint").Linter.FlatConfig}
31
- * The configuration entry.
32
- */
33
- function languageOptions(sourceType, ...extensions) {
17
+ // returns language options for specific file extensions
18
+ const languageOptions = (sourceType, ...extensions) => {
34
19
  const { ecmaVersion } = options;
35
20
  return {
36
21
  files: extensions.map(ext => "*/**." + ext),
37
22
  languageOptions: { ecmaVersion, sourceType },
38
23
  };
39
- }
40
-
24
+ };
41
25
  return [
42
-
43
26
  // global linter configuration
44
27
  {
45
28
  linterOptions: {
@@ -47,16 +30,12 @@ export default function base(options) {
47
30
  reportUnusedDisableDirectives: "error",
48
31
  },
49
32
  },
50
-
51
33
  // ECMA version and module type for ES modules
52
34
  languageOptions("module", "mjs", "mts"),
53
-
54
35
  // ECMA version and module type for CommonJS modules
55
36
  languageOptions("commonjs", "cjs", "cts"),
56
-
57
37
  // ECMA version and module type for *.js and *.ts files
58
38
  languageOptions(options.sourceType, "js", "jsx", "ts", "tsx"),
59
-
60
39
  // configure linter rules
61
40
  {
62
41
  files: ["**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"],
@@ -0,0 +1,11 @@
1
+ import type { TSESLint } from "@typescript-eslint/utils";
2
+ /**
3
+ * Checks inline linter directives.
4
+ *
5
+ * Wraps the following packages:
6
+ * - `eslint-plugin-eslint-comments`
7
+ *
8
+ * @returns
9
+ * An array of configuration objects to be added to the flat configuration.
10
+ */
11
+ export default function directives(): TSESLint.FlatConfig.ConfigArray;
@@ -1,19 +1,15 @@
1
-
2
1
  import commentsPluginConfigs from "@eslint-community/eslint-plugin-eslint-comments/configs";
3
-
4
2
  // functions ==================================================================
5
-
6
3
  /**
7
4
  * Checks inline linter directives.
8
5
  *
9
6
  * Wraps the following packages:
10
7
  * - `eslint-plugin-eslint-comments`
11
8
  *
12
- * @returns {import("../shared/types").FlatConfigArray}
9
+ * @returns
13
10
  * An array of configuration objects to be added to the flat configuration.
14
11
  */
15
12
  export default function directives() {
16
-
17
13
  return [
18
14
  // register rule implementations and recommended rules
19
15
  commentsPluginConfigs.recommended,
@@ -0,0 +1,15 @@
1
+ import type { TSESLint } from "@typescript-eslint/utils";
2
+ import type { LanguageOptions } from "../shared/env-utils.js";
3
+ /**
4
+ * Adds linter rules for `import` and `export` statements.
5
+ *
6
+ * Wraps the following packages:
7
+ * - `eslint-plugin-import`
8
+ *
9
+ * @param options
10
+ * Resolved configuration options.
11
+ *
12
+ * @returns
13
+ * An array of configuration objects to be added to the flat configuration.
14
+ */
15
+ export default function importConfig(options: Required<LanguageOptions>): TSESLint.FlatConfig.ConfigArray;
@@ -0,0 +1,58 @@
1
+ import importPlugin from "eslint-plugin-import";
2
+ import { fixupPluginRules } from "@eslint/compat";
3
+ // exports ====================================================================
4
+ /**
5
+ * Adds linter rules for `import` and `export` statements.
6
+ *
7
+ * Wraps the following packages:
8
+ * - `eslint-plugin-import`
9
+ *
10
+ * @param options
11
+ * Resolved configuration options.
12
+ *
13
+ * @returns
14
+ * An array of configuration objects to be added to the flat configuration.
15
+ */
16
+ export default function importConfig(options) {
17
+ // configuration properties
18
+ const { ecmaVersion, sourceType } = options;
19
+ // extensions of ES module files
20
+ const jsExtensions = (sourceType === "module") ? [".js", ".mjs"] : [".mjs"];
21
+ const tsExtensions = (sourceType === "module") ? [".ts", ".mts"] : [".mts"];
22
+ return [{
23
+ files: [
24
+ ...jsExtensions.map(ext => "**/*" + ext),
25
+ ...tsExtensions.map(ext => "**/*" + ext),
26
+ ],
27
+ // register rule implementations of the plugin
28
+ plugins: {
29
+ import: fixupPluginRules(importPlugin), // https://github.com/import-js/eslint-plugin-import/issues/2948
30
+ },
31
+ // language options need to be repeated for this plugin
32
+ languageOptions: {
33
+ parserOptions: {
34
+ ecmaVersion,
35
+ sourceType: "module",
36
+ },
37
+ },
38
+ // parser settings need to be repeated for this plugin
39
+ settings: {
40
+ "import/parsers": {
41
+ espree: jsExtensions,
42
+ "@typescript-eslint/parser": tsExtensions,
43
+ },
44
+ },
45
+ // reconfigure plugin rules
46
+ rules: {
47
+ // recommended rules
48
+ ...importPlugin.configs.recommended.rules,
49
+ ...importPlugin.configs.typescript.rules,
50
+ // change or disable a few recommended rules
51
+ "import/default": "off",
52
+ "import/no-duplicates": "error",
53
+ "import/no-named-as-default": "off",
54
+ "import/no-named-as-default-member": "off",
55
+ "import/no-unresolved": "off",
56
+ },
57
+ }];
58
+ }
@@ -0,0 +1,9 @@
1
+ import type { TSESLint } from "@typescript-eslint/utils";
2
+ /**
3
+ * Defines additional standard rules targeting JavaScript but _not_ TypeScript
4
+ * source files.
5
+ *
6
+ * @returns
7
+ * An array of configuration objects to be added to the flat configuration.
8
+ */
9
+ export default function js(): TSESLint.FlatConfig.ConfigArray;
@@ -0,0 +1,32 @@
1
+ import { NO_UNUSED_VARS_OPTIONS } from "../shared/env-utils.js";
2
+ // functions ==================================================================
3
+ /**
4
+ * Defines additional standard rules targeting JavaScript but _not_ TypeScript
5
+ * source files.
6
+ *
7
+ * @returns
8
+ * An array of configuration objects to be added to the flat configuration.
9
+ */
10
+ export default function js() {
11
+ return [{
12
+ files: ["**/*.{js,jsx,cjs,mjs}"],
13
+ rules: {
14
+ // possible problems
15
+ "no-duplicate-imports": "error",
16
+ "no-loss-of-precision": "off",
17
+ "no-unused-vars": ["error", NO_UNUSED_VARS_OPTIONS],
18
+ // suggestions
19
+ "default-param-last": "error",
20
+ "dot-notation": "error",
21
+ "no-array-constructor": "error",
22
+ "no-invalid-this": "error",
23
+ "no-loop-func": "error",
24
+ "no-redeclare": "error",
25
+ "no-shadow": ["error", { ignoreOnInitialization: true }],
26
+ "no-throw-literal": "error",
27
+ "no-useless-constructor": "error",
28
+ "prefer-promise-reject-errors": "error",
29
+ "require-await": "error",
30
+ },
31
+ }];
32
+ }
@@ -0,0 +1,11 @@
1
+ import type { TSESLint } from "@typescript-eslint/utils";
2
+ /**
3
+ * Checks the JSDoc comments in source files.
4
+ *
5
+ * Wraps the following packages:
6
+ * - `eslint-plugin-jsdoc`
7
+ *
8
+ * @returns
9
+ * An array of configuration objects to be added to the flat configuration.
10
+ */
11
+ export default function jsdoc(): TSESLint.FlatConfig.ConfigArray;
@@ -1,24 +1,18 @@
1
-
2
1
  import jsdocPlugin from "eslint-plugin-jsdoc";
3
-
4
2
  // functions ==================================================================
5
-
6
3
  /**
7
4
  * Checks the JSDoc comments in source files.
8
5
  *
9
6
  * Wraps the following packages:
10
7
  * - `eslint-plugin-jsdoc`
11
8
  *
12
- * @returns {import("../shared/types").FlatConfigArray}
9
+ * @returns
13
10
  * An array of configuration objects to be added to the flat configuration.
14
11
  */
15
12
  export default function jsdoc() {
16
-
17
13
  return [
18
-
19
14
  // register rule implementations and recommended rules
20
15
  jsdocPlugin.configs["flat/recommended-error"],
21
-
22
16
  // general configuration
23
17
  {
24
18
  settings: {
@@ -35,7 +29,6 @@ export default function jsdoc() {
35
29
  },
36
30
  },
37
31
  },
38
-
39
32
  // overrides for TypeScript files
40
33
  {
41
34
  files: ["**/*.{ts,tsx,cts,mts}"],
@@ -44,7 +37,6 @@ export default function jsdoc() {
44
37
  "jsdoc/check-param-names": ["error", { allowExtraTrailingParamDocs: true }], // overload signatures
45
38
  },
46
39
  },
47
-
48
40
  // configure plugin rules
49
41
  {
50
42
  rules: {
@@ -0,0 +1,15 @@
1
+ import type { TSESLint } from "@typescript-eslint/utils";
2
+ import type { StylisticOptions } from "../shared/env-utils.js";
3
+ /**
4
+ * Defines standard linting rules for JSON files.
5
+ *
6
+ * Wraps the following packages:
7
+ * - `eslint-plugin-jsonc`
8
+ *
9
+ * @param options
10
+ * Resolved configuration options.
11
+ *
12
+ * @returns
13
+ * An array of configuration objects to be added to the flat configuration.
14
+ */
15
+ export default function json(options: Required<StylisticOptions>): TSESLint.FlatConfig.ConfigArray;
@@ -1,27 +1,21 @@
1
-
2
1
  import jsonPlugin from "eslint-plugin-jsonc";
3
-
4
2
  // functions ==================================================================
5
-
6
3
  /**
7
4
  * Defines standard linting rules for JSON files.
8
5
  *
9
6
  * Wraps the following packages:
10
7
  * - `eslint-plugin-jsonc`
11
8
  *
12
- * @param {Required<import("../shared/types").StylisticOptions>} options
9
+ * @param options
13
10
  * Resolved configuration options.
14
11
  *
15
- * @returns {import("../shared/types").FlatConfigArray}
12
+ * @returns
16
13
  * An array of configuration objects to be added to the flat configuration.
17
14
  */
18
15
  export default function json(options) {
19
-
20
16
  return [
21
-
22
17
  // register rule implementations and recommended rules
23
18
  ...jsonPlugin.configs["flat/recommended-with-json"],
24
-
25
19
  // reconfigure plugin rules
26
20
  {
27
21
  rules: {
@@ -0,0 +1,14 @@
1
+ import type { TSESLint } from "@typescript-eslint/utils";
2
+ /**
3
+ * Checks the existence of license headers in source files.
4
+ *
5
+ * Wraps the following packages:
6
+ * - `eslint-plugin-license-header`
7
+ *
8
+ * @param path
9
+ * Path to the template file containing the license header.
10
+ *
11
+ * @returns
12
+ * An array of configuration objects to be added to the flat configuration.
13
+ */
14
+ export default function license(path: string): TSESLint.FlatConfig.ConfigArray;
@@ -1,33 +1,27 @@
1
-
2
1
  import licensePlugin from "eslint-plugin-license-header";
3
-
4
2
  // functions ==================================================================
5
-
6
3
  /**
7
4
  * Checks the existence of license headers in source files.
8
5
  *
9
6
  * Wraps the following packages:
10
7
  * - `eslint-plugin-license-header`
11
8
  *
12
- * @param {string} path
9
+ * @param path
13
10
  * Path to the template file containing the license header.
14
11
  *
15
- * @returns {import("../shared/types").FlatConfigArray}
12
+ * @returns
16
13
  * An array of configuration objects to be added to the flat configuration.
17
14
  */
18
15
  export default function license(path) {
19
-
20
16
  return [{
21
- files: ["**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"],
22
-
23
- // register rule implementations of the plugin
24
- plugins: {
25
- "license-header": licensePlugin,
26
- },
27
-
28
- // configure plugin rules
29
- rules: {
30
- "license-header/header": ["error", path],
31
- },
32
- }];
17
+ files: ["**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"],
18
+ // register rule implementations of the plugin
19
+ plugins: {
20
+ "license-header": licensePlugin,
21
+ },
22
+ // configure plugin rules
23
+ rules: {
24
+ "license-header/header": ["error", path],
25
+ },
26
+ }];
33
27
  }
@@ -0,0 +1,11 @@
1
+ import type { TSESLint } from "@typescript-eslint/utils";
2
+ /**
3
+ * Checks for correct usage of native promises.
4
+ *
5
+ * Wraps the following packages:
6
+ * - `eslint-plugin-promise`
7
+ *
8
+ * @returns
9
+ * An array of configuration objects to be added to the flat configuration.
10
+ */
11
+ export default function promises(): TSESLint.FlatConfig.ConfigArray;
@@ -1,32 +1,26 @@
1
-
2
1
  import promisePlugin from "eslint-plugin-promise";
3
-
4
2
  // functions ==================================================================
5
-
6
3
  /**
7
4
  * Checks for correct usage of native promises.
8
5
  *
9
6
  * Wraps the following packages:
10
7
  * - `eslint-plugin-promise`
11
8
  *
12
- * @returns {import("../shared/types").FlatConfigArray}
9
+ * @returns
13
10
  * An array of configuration objects to be added to the flat configuration.
14
11
  */
15
12
  export default function promises() {
16
-
17
13
  return [
18
-
19
14
  // register rule implementations and recommended rules
20
15
  promisePlugin.configs["flat/recommended"],
21
-
22
16
  // reconfigure plugin rules
23
17
  {
24
18
  rules: {
25
19
  "promise/always-return": ["error", { ignoreLastCallback: true }],
26
20
  "promise/no-callback-in-promise": "off",
27
- "promise/no-nesting": "error", // warning => error
21
+ "promise/no-nesting": "error", // warning => error
28
22
  "promise/no-return-in-finally": "error",
29
- "promise/valid-params": "error", // warning => error
23
+ "promise/valid-params": "error", // warning => error
30
24
  },
31
25
  },
32
26
  ];
@@ -0,0 +1,16 @@
1
+ import type { TSESLint } from "@typescript-eslint/utils";
2
+ import type { StylisticOptions } from "../shared/env-utils.js";
3
+ /**
4
+ * Defines standard (opinionated) linter rules for source code style.
5
+ *
6
+ * Wraps the following packages:
7
+ * - `@stylistic/eslint-plugin`
8
+ * - `@stylistic/eslint-plugin-migrate`
9
+ *
10
+ * @param options
11
+ * Resolved configuration options.
12
+ *
13
+ * @returns
14
+ * An array of configuration objects to be added to the flat configuration.
15
+ */
16
+ export default function stylistic(options: Required<StylisticOptions>): TSESLint.FlatConfig.ConfigArray;
@@ -1,9 +1,6 @@
1
-
2
1
  import stylisticPlugin from "@stylistic/eslint-plugin";
3
2
  import migratePlugin from "@stylistic/eslint-plugin-migrate";
4
-
5
3
  // functions ==================================================================
6
-
7
4
  /**
8
5
  * Defines standard (opinionated) linter rules for source code style.
9
6
  *
@@ -11,29 +8,24 @@ import migratePlugin from "@stylistic/eslint-plugin-migrate";
11
8
  * - `@stylistic/eslint-plugin`
12
9
  * - `@stylistic/eslint-plugin-migrate`
13
10
  *
14
- * @param {Required<import("../shared/types").StylisticOptions>} options
11
+ * @param options
15
12
  * Resolved configuration options.
16
13
  *
17
- * @returns {import("../shared/types").FlatConfigArray}
14
+ * @returns
18
15
  * An array of configuration objects to be added to the flat configuration.
19
16
  */
20
17
  export default function stylistic(options) {
21
-
22
18
  // configuration properties
23
19
  const { indent, semi, quotes, dangle } = options;
24
-
25
20
  return [
26
-
27
21
  // globally disable all deprecated stylistic core rules
28
22
  stylisticPlugin.configs["disable-legacy"],
29
-
30
23
  // "@stylistic" plugin
31
24
  {
32
25
  // register rule implementations of the plugins
33
26
  plugins: {
34
27
  "@stylistic": stylisticPlugin,
35
28
  },
36
-
37
29
  // configure plugin rules
38
30
  rules: {
39
31
  "@stylistic/array-bracket-spacing": "error",
@@ -68,16 +60,16 @@ export default function stylistic(options) {
68
60
  "@stylistic/no-extra-semi": "error",
69
61
  "@stylistic/no-floating-decimal": "error",
70
62
  "@stylistic/no-mixed-operators": ["error", {
71
- groups: [
72
- // allow to mix arithmetic operators
73
- // ["+", "-", "*", "/", "%", "**"],
74
- ["&", "|", "^", "~", "<<", ">>", ">>>"],
75
- ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
76
- ["&&", "||"],
77
- ["in", "instanceof"],
78
- ],
79
- allowSamePrecedence: true,
80
- }],
63
+ groups: [
64
+ // allow to mix arithmetic operators
65
+ // ["+", "-", "*", "/", "%", "**"],
66
+ ["&", "|", "^", "~", "<<", ">>", ">>>"],
67
+ ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
68
+ ["&&", "||"],
69
+ ["in", "instanceof"],
70
+ ],
71
+ allowSamePrecedence: true,
72
+ }],
81
73
  "@stylistic/no-multiple-empty-lines": ["error", { max: 2 }],
82
74
  "@stylistic/no-tabs": "error",
83
75
  "@stylistic/no-trailing-spaces": "error",
@@ -104,14 +96,12 @@ export default function stylistic(options) {
104
96
  "@stylistic/yield-star-spacing": "error",
105
97
  },
106
98
  },
107
-
108
99
  // "@stylistic/migrate" plugin
109
100
  {
110
101
  // register rule implementations of the plugins
111
102
  plugins: {
112
103
  "@stylistic/migrate": migratePlugin,
113
104
  },
114
-
115
105
  // configure plugin rules
116
106
  rules: {
117
107
  "@stylistic/migrate/migrate-js": "error",
@@ -0,0 +1,11 @@
1
+ import type { TSESLint } from "@typescript-eslint/utils";
2
+ /**
3
+ * Defines standard rules for TypeScript source files.
4
+ *
5
+ * Wraps the following packages:
6
+ * - `typescript-eslint`
7
+ *
8
+ * @returns
9
+ * An array of configuration objects to be added to the flat configuration.
10
+ */
11
+ export default function ts(): TSESLint.FlatConfig.ConfigArray;