@open-xchange/linter-presets 0.2.0 → 0.3.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,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.0] - 2024-08-01
4
+
5
+ - chore: [ESLint] [major bump of `typescript-eslint` to v8](https://typescript-eslint.io/blog/announcing-typescript-eslint-v8/)
6
+ - removed: [ESLint] environment `env.tsconfig` (always using `projectService` of `typescript-eslint` instead)
7
+ - changed: [ESLint] pattern for unused variables is now `^_.` (instead `^_`) to detect dangling underscore imports
8
+
3
9
  ## [0.2.0] - 2024-07-31
4
10
 
5
11
  - chore: bump dependencies
@@ -17,6 +17,7 @@ export default function ts() {
17
17
  // suppress warning for new TypeScript versions
18
18
  languageOptions: {
19
19
  parserOptions: {
20
+ projectService: true,
20
21
  warnOnUnsupportedTypeScriptVersion: false,
21
22
  },
22
23
  },
@@ -32,7 +33,6 @@ export default function ts() {
32
33
  "@typescript-eslint/consistent-type-exports": "error",
33
34
  "@typescript-eslint/consistent-type-imports": ["error", { disallowTypeAnnotations: false }],
34
35
  "@typescript-eslint/default-param-last": "error",
35
- "@typescript-eslint/dot-notation": "error",
36
36
  "@typescript-eslint/explicit-function-return-type": ["error", {
37
37
  allowExpressions: true,
38
38
  allowTypedFunctionExpressions: true,
@@ -40,12 +40,11 @@ export default function ts() {
40
40
  allowConciseArrowFunctionExpressionsStartingWithVoid: true,
41
41
  }],
42
42
  "@typescript-eslint/no-array-constructor": "error",
43
- "@typescript-eslint/no-array-delete": "error",
44
43
  "@typescript-eslint/no-duplicate-type-constituents": "error",
45
44
  "@typescript-eslint/no-empty-function": ["error", {
46
45
  allow: ["private-constructors", "protected-constructors", "decoratedFunctions", "overrideMethods"],
47
46
  }],
48
- "@typescript-eslint/no-empty-interface": "off",
47
+ "@typescript-eslint/no-empty-object-type": ["error", { allowInterfaces: "always" }],
49
48
  "@typescript-eslint/no-explicit-any": "off",
50
49
  "@typescript-eslint/no-import-type-side-effects": "error",
51
50
  "@typescript-eslint/no-invalid-this": "error",
@@ -56,19 +55,11 @@ export default function ts() {
56
55
  "@typescript-eslint/no-redeclare": "error",
57
56
  "@typescript-eslint/no-shadow": ["error", { ignoreOnInitialization: true }],
58
57
  "@typescript-eslint/no-unnecessary-template-expression": "error",
59
- "@typescript-eslint/no-unsafe-enum-comparison": "error",
60
- "@typescript-eslint/no-unsafe-function-type": "error",
61
- "@typescript-eslint/no-unsafe-unary-minus": "error",
62
58
  "@typescript-eslint/no-unused-vars": ["error", NO_UNUSED_VARS_OPTIONS],
63
59
  "@typescript-eslint/no-useless-constructor": "error",
64
- "@typescript-eslint/no-wrapper-object-types": "error",
65
- "@typescript-eslint/only-throw-error": "error",
66
- "@typescript-eslint/prefer-find": "error",
67
60
  "@typescript-eslint/prefer-literal-enum-member": "error",
68
- "@typescript-eslint/prefer-nullish-coalescing": "off",
69
- "@typescript-eslint/prefer-promise-reject-errors": "error",
61
+ "@typescript-eslint/prefer-nullish-coalescing": ["error", { ignorePrimitives: true }],
70
62
  "@typescript-eslint/prefer-readonly": "error",
71
- "@typescript-eslint/require-await": "error",
72
63
  "@typescript-eslint/restrict-template-expressions": "off",
73
64
  "@typescript-eslint/return-await": ["error", "always"],
74
65
  "@typescript-eslint/switch-exhaustiveness-check": "error",
@@ -1,6 +1,5 @@
1
1
  import type { TSESLint } from "@typescript-eslint/utils";
2
2
  import type { LanguageOptions, StylisticOptions } from "./shared/env-utils.js";
3
- import tsconfig from "./env/tsconfig.js";
4
3
  import node from "./env/node.js";
5
4
  import browser from "./env/browser.js";
6
5
  import jest from "./env/jest.js";
@@ -40,7 +39,6 @@ export interface ConfigureOptions {
40
39
  * A collection with all available environment presets.
41
40
  */
42
41
  export declare const env: {
43
- tsconfig: typeof tsconfig;
44
42
  node: typeof node;
45
43
  browser: typeof browser;
46
44
  jest: typeof jest;
@@ -9,7 +9,6 @@ import imports from "./config/imports.js";
9
9
  import promises from "./config/promises.js";
10
10
  import jsdoc from "./config/jsdoc.js";
11
11
  import stylistic from "./config/stylistic.js";
12
- import tsconfig from "./env/tsconfig.js";
13
12
  import node from "./env/node.js";
14
13
  import browser from "./env/browser.js";
15
14
  import jest from "./env/jest.js";
@@ -23,7 +22,6 @@ import eslint from "./env/eslint.js";
23
22
  * A collection with all available environment presets.
24
23
  */
25
24
  export const env = {
26
- tsconfig,
27
25
  node,
28
26
  browser,
29
27
  jest,
@@ -1,3 +1,3 @@
1
1
  import { type TSESLint } from "@typescript-eslint/utils";
2
- declare const _default: TSESLint.RuleModule<"UNEXPECTED_DIRECTIVE" | "UNEXPECTED_DIRECTIVE_FIX", [], TSESLint.RuleListener>;
2
+ declare const _default: TSESLint.RuleModule<"UNEXPECTED_DIRECTIVE" | "UNEXPECTED_DIRECTIVE_FIX", [], unknown, TSESLint.RuleListener>;
3
3
  export default _default;
@@ -21,5 +21,5 @@ export interface RuleNoInvalidHierarchyPackage {
21
21
  export type RuleNoInvalidHierarchyOptions = Record<string, RuleNoInvalidHierarchyPackage>;
22
22
  type RuleOptions = [RuleNoInvalidHierarchyOptions];
23
23
  type RuleMessageIds = "UNEXPECTED_OPTIONAL_STATIC" | "INVALID_PACKAGE_HIERARCHY";
24
- declare const _default: ESLintUtils.RuleModule<RuleMessageIds, RuleOptions, ESLintUtils.RuleListener>;
24
+ declare const _default: ESLintUtils.RuleModule<RuleMessageIds, RuleOptions, unknown, ESLintUtils.RuleListener>;
25
25
  export default _default;
@@ -6,5 +6,5 @@ export interface RuleNoInvalidModulesOptions {
6
6
  external?: string[];
7
7
  }
8
8
  type RuleOptions = [Required<RuleNoInvalidModulesOptions>];
9
- declare const _default: ESLintUtils.RuleModule<"SOURCE_FILE_NOT_FOUND", RuleOptions, ESLintUtils.RuleListener>;
9
+ declare const _default: ESLintUtils.RuleModule<"SOURCE_FILE_NOT_FOUND", RuleOptions, unknown, ESLintUtils.RuleListener>;
10
10
  export default _default;
@@ -4,9 +4,9 @@
4
4
  * `@typescript-eslint/no-unused-vars`.
5
5
  */
6
6
  export const NO_UNUSED_VARS_OPTIONS = {
7
- varsIgnorePattern: "^_",
8
- argsIgnorePattern: "^_",
9
- destructuredArrayIgnorePattern: "^_",
7
+ varsIgnorePattern: "^_.",
8
+ argsIgnorePattern: "^_.",
9
+ destructuredArrayIgnorePattern: "^_.",
10
10
  caughtErrors: "all",
11
11
  ignoreRestSiblings: true,
12
12
  };
@@ -22,7 +22,7 @@ export const NO_UNUSED_VARS_OPTIONS = {
22
22
  * The concatenated and flattened array.
23
23
  */
24
24
  function flatten(...entries) {
25
- return entries.flatMap(array => array || []);
25
+ return entries.flatMap(array => array ?? []);
26
26
  }
27
27
  /**
28
28
  * Creates a rules record for all restricted items.
@@ -141,7 +141,7 @@ export function restrictedRules(envOptions, fixed) {
141
141
  * custom rule settings, otherwise `undefined`.
142
142
  */
143
143
  export function customRules(envOptions, rules) {
144
- return (rules || envOptions.rules) && createConfig(envOptions, {
144
+ return (rules ?? envOptions.rules) && createConfig(envOptions, {
145
145
  rules: { ...rules, ...envOptions.rules },
146
146
  });
147
147
  }
@@ -73,7 +73,6 @@ The names of the environment presets are linked to detailed descriptions.
73
73
 
74
74
  | Name | Description |
75
75
  | - | - |
76
- | [`env.tsconfig`](./env/tsconfig.md) | TypeScript project setup (per `tsconfig.json` file). |
77
76
  | [`env.node`](./env/node.md) | Modules running in NodeJS. |
78
77
  | [`env.browser`](./env/browser.md) | Modules running in browsers. |
79
78
  | [`env.react`](./env/react.md) | Modules using [React](https://react.dev/) library. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xchange/linter-presets",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Configuration presets for ESLint and StyleLint",
5
5
  "repository": {
6
6
  "url": "https://gitlab.open-xchange.com/fspd/npm-packages/linter-presets"
@@ -61,13 +61,13 @@
61
61
  "stylelint-config-standard-less": "3.0.1",
62
62
  "stylelint-config-standard-scss": "13.1.0",
63
63
  "stylelint-plugin-license-header": "1.0.3",
64
- "typescript-eslint": "7.18.0"
64
+ "typescript-eslint": "8.0.0"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@types/confusing-browser-globals": "1.0.3",
68
68
  "@types/eslint__js": "8.42.3",
69
69
  "@types/picomatch": "3.0.0",
70
- "@typescript-eslint/utils": "7.18.0",
70
+ "@typescript-eslint/utils": "8.0.0",
71
71
  "eslint": "9.8.0",
72
72
  "husky": "9.1.4",
73
73
  "jest": "29.7.0",
@@ -1,21 +0,0 @@
1
- import type { TSESLint } from "@typescript-eslint/utils";
2
- import type { EnvBaseOptions } from "../shared/env-utils.js";
3
- /**
4
- * Configuration options for the environment preset "env.tsconfig".
5
- */
6
- export interface EnvTSConfigOptions extends EnvBaseOptions {
7
- /**
8
- * The path to the TypeScript project configuration file (`tsconfig.json`).
9
- */
10
- project: string;
11
- }
12
- /**
13
- * Creates configuration objects for TypeScript projects.
14
- *
15
- * @param envOptions
16
- * Configuration options for the environment.
17
- *
18
- * @returns
19
- * An array of configuration objects to be added to the flat configuration.
20
- */
21
- export default function tsconfig(envOptions: EnvTSConfigOptions): TSESLint.FlatConfig.ConfigArray;
@@ -1,24 +0,0 @@
1
- import { concatConfigs, createConfig, customRules } from "../shared/env-utils.js";
2
- // functions ==================================================================
3
- /**
4
- * Creates configuration objects for TypeScript projects.
5
- *
6
- * @param envOptions
7
- * Configuration options for the environment.
8
- *
9
- * @returns
10
- * An array of configuration objects to be added to the flat configuration.
11
- */
12
- export default function tsconfig(envOptions) {
13
- return concatConfigs(
14
- // path to project configuration file
15
- createConfig(envOptions, {
16
- languageOptions: {
17
- parserOptions: {
18
- project: envOptions.project,
19
- },
20
- },
21
- }),
22
- // custom rules
23
- customRules(envOptions));
24
- }
@@ -1,35 +0,0 @@
1
- # Environment `env.tsconfig`
2
-
3
- Creates configuration objects for TypeScript projects (registers a `tsconfig.json` file in the project).
4
-
5
- ## Signature
6
-
7
- ```ts
8
- function tsconfig(options: EnvTSConfigOptions): Linter.FlatConfig[]
9
- ```
10
-
11
- ## Options
12
-
13
- | Name | Type | Default | Description |
14
- | - | - | - | - |
15
- | `files` | `string[]` | _required_ | Glob patterns for source files to be included. |
16
- | `ignores` | `string[]` | `[]` | Glob patterns for source files matching `files` to be ignored. |
17
- | `project` | `string` | _required_ | The absolute path to the TypeScript project configuration file (`tsconfig.json`). |
18
- | `rules` | `Linter.RulesRecord` | `{}` | Additional linter rules to be added to the configuration. |
19
-
20
- ## Example
21
-
22
- ```js
23
- // eslint.config.js
24
- import { utils, eslint } from "@open-xchange/linter-presets"
25
-
26
- const resolve = utils.resolver(import.meta.url)
27
-
28
- export default [
29
- ...eslint.configure({ /* ... */ }),
30
- ...eslint.env.tsconfig({
31
- files: ["src/**/*.ts"],
32
- project: resolve("src/tsconfig.json"),
33
- }),
34
- ]
35
- ```