@open-xchange/linter-presets 0.1.1 → 0.1.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.
- package/CHANGELOG.md +9 -1
- package/dist/eslint/env/project.js +0 -20
- package/dist/eslint/rules/no-amd-module-directive.js +0 -20
- package/dist/eslint/rules/no-invalid-modules.js +0 -20
- package/dist/eslint/shared/env-utils.d.ts +16 -1
- package/dist/eslint/shared/env-utils.js +9 -15
- package/dist/eslint/shared/rule-utils.js +0 -20
- package/doc/eslint/env/browser.md +15 -0
- package/doc/eslint/env/node.md +10 -0
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.3] - 2024-07-15
|
|
4
|
+
|
|
5
|
+
- chore: bump dependencies
|
|
6
|
+
|
|
7
|
+
## [0.1.2] - 2024-07-12
|
|
8
|
+
|
|
9
|
+
- added: [ESLint] option `restricted.nativeDecorators`
|
|
10
|
+
|
|
3
11
|
## [0.1.1] - 2024-07-11
|
|
4
12
|
|
|
5
|
-
- changed: [ESLint]
|
|
13
|
+
- changed: [ESLint] option `stylistic.semi` as enum (always/never/off)
|
|
6
14
|
|
|
7
15
|
## [0.1.0] - 2024-07-10
|
|
8
16
|
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
*
|
|
5
|
-
* This code is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU Affero General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
-
* along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
|
17
|
-
*
|
|
18
|
-
* Any use of the work other than as authorized under this license or copyright law is prohibited.
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
1
|
import noAmdModuleDirective from "../rules/no-amd-module-directive.js";
|
|
22
2
|
import noInvalidModules from "../rules/no-invalid-modules.js";
|
|
23
3
|
// exports ====================================================================
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
*
|
|
5
|
-
* This code is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU Affero General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
-
* along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
|
17
|
-
*
|
|
18
|
-
* Any use of the work other than as authorized under this license or copyright law is prohibited.
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
1
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
22
2
|
// exports ====================================================================
|
|
23
3
|
export default ESLintUtils.RuleCreator.withoutDocs({
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
*
|
|
5
|
-
* This code is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU Affero General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
-
* along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
|
17
|
-
*
|
|
18
|
-
* Any use of the work other than as authorized under this license or copyright law is prohibited.
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
1
|
import { createRequire } from "node:module";
|
|
22
2
|
import { posix, dirname, extname } from "node:path";
|
|
23
3
|
import { packageUpSync } from "package-up";
|
|
@@ -120,9 +120,24 @@ export interface EnvRestrictedItems {
|
|
|
120
120
|
export interface EnvRestrictedOverride extends EnvFilesOptions, EnvRestrictedItems {
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
|
-
* Configuration options for
|
|
123
|
+
* Configuration options for banned globals, imports, properties, and syntax
|
|
124
|
+
* constructs in the environment.
|
|
124
125
|
*/
|
|
125
126
|
export interface EnvRestrictedOptions extends EnvRestrictedItems {
|
|
127
|
+
/**
|
|
128
|
+
* Whether the environment supports native decorators. In this case, it
|
|
129
|
+
* will be required to replace TypeScript decorated `private` methods with
|
|
130
|
+
* native `#private` methods.
|
|
131
|
+
*
|
|
132
|
+
* Default value is `false` (TypeScript's experimental decorators cannot be
|
|
133
|
+
* used with native `#private` fields).
|
|
134
|
+
*/
|
|
135
|
+
nativeDecorators?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Overrides for specific subsets of files in the environment. All
|
|
138
|
+
* restricted items of overrides will be merged with the common restricted
|
|
139
|
+
* items defined for the entire environment.
|
|
140
|
+
*/
|
|
126
141
|
overrides?: EnvRestrictedOverride[];
|
|
127
142
|
}
|
|
128
143
|
export interface EnvRestrictedRulesResult {
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
// constants ==================================================================
|
|
2
|
-
/**
|
|
3
|
-
* Global symbols to be banned in all source code files.
|
|
4
|
-
*/
|
|
5
|
-
const RESTRICTED_GLOBALS = [
|
|
6
|
-
{ name: "isFinite", message: "Use 'Number.isFinite' instead." },
|
|
7
|
-
{ name: "isNaN", message: "Use 'Number.isNaN' instead." },
|
|
8
|
-
];
|
|
9
|
-
/**
|
|
10
|
-
* Syntax constructs to be banned in all source code files.
|
|
11
|
-
*/
|
|
12
|
-
const RESTRICTED_SYNTAX = [
|
|
13
|
-
{ selector: ":matches(PropertyDefinition, MethodDefinition[kind!='constructor'])[accessibility='public']", message: "Remove 'public' keyword." },
|
|
14
|
-
{ selector: ":matches(PropertyDefinition, MethodDefinition[kind!='constructor'])[accessibility='private'][decorators.length=0]", message: "Use #private syntax instead." },
|
|
15
|
-
{ selector: "MethodDefinition[kind='constructor'] TSParameterProperty[accessibility]", message: "Use explicit class properties." },
|
|
16
|
-
];
|
|
17
2
|
/**
|
|
18
3
|
* Shared options for the core rule `no-unused-vars`, and the plugin rule
|
|
19
4
|
* `@typescript-eslint/no-unused-vars`.
|
|
@@ -76,6 +61,15 @@ function createRulesRecord(generator) {
|
|
|
76
61
|
* The generated linter rules to forbid the restricted items.
|
|
77
62
|
*/
|
|
78
63
|
export function generateRestrictedRules(fixed, options) {
|
|
64
|
+
const RESTRICTED_GLOBALS = [
|
|
65
|
+
{ name: "isFinite", message: "Use 'Number.isFinite' instead." },
|
|
66
|
+
{ name: "isNaN", message: "Use 'Number.isNaN' instead." },
|
|
67
|
+
];
|
|
68
|
+
const RESTRICTED_SYNTAX = [
|
|
69
|
+
{ selector: ":matches(PropertyDefinition, MethodDefinition[kind!='constructor'])[accessibility='public']", message: "Remove 'public' keyword." },
|
|
70
|
+
{ selector: ":matches(PropertyDefinition, MethodDefinition[kind!='constructor'])[accessibility='private']" + (options?.nativeDecorators ? "" : "[decorators.length=0]"), message: "Use #private syntax instead." },
|
|
71
|
+
{ selector: "MethodDefinition[kind='constructor'] TSParameterProperty[accessibility]", message: "Use explicit class properties." },
|
|
72
|
+
];
|
|
79
73
|
// restricted items for all files in the environment
|
|
80
74
|
const items = {
|
|
81
75
|
globals: concatArrays(RESTRICTED_GLOBALS, fixed.globals, options?.globals),
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
*
|
|
5
|
-
* This code is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU Affero General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
-
* along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
|
17
|
-
*
|
|
18
|
-
* Any use of the work other than as authorized under this license or copyright law is prohibited.
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
1
|
import { posix, sep } from "node:path";
|
|
22
2
|
import { lstatSync } from "node:fs";
|
|
23
3
|
import pm from "picomatch";
|
|
@@ -32,8 +32,23 @@ The option `restricted` is an object with the following properties:
|
|
|
32
32
|
| `imports` | `EnvRestrictedName[]` | `[]` | Banned modules that must not be imported. Each entry is an object with string properties `name` and `message`. |
|
|
33
33
|
| `properties` | `EnvRestrictedProperty[]` | `[]` | Banned object properties. Each entry is an object with string properties `object`, `property`, and `message`). |
|
|
34
34
|
| `syntax` | `EnvRestrictedSyntax[]` | `[]` | Banned syntax constructs by [AST selectors](https://eslint.org/docs/latest/extend/selectors). Each entry is an object with string properties `selector` and `message`. |
|
|
35
|
+
| `nativeDecorators` | `boolean` | `false` | Whether the environment supports native decorators. In this case, it will be required to replace decorated TypeScript `private` methods with native `#private` methods (TypeScript's experimental decorators cannot be used with native `#private` fields). |
|
|
35
36
|
| `overrides` | `EnvRestrictedOverride[]` | `[]` | Overrides for specific subsets of files in the environment. Each entry is an object with the common properties `files` (required) and `ignores`, and the properties `globals`, `imports`, `properties`, and `syntax` to specify restricted items (see above). All restricted items of overrides will be merged with the common restricted items defined for the entire environment. |
|
|
36
37
|
|
|
38
|
+
The environment `env.browser` already defines the following built-in restrictions:
|
|
39
|
+
|
|
40
|
+
| Type | Name | Description |
|
|
41
|
+
| - | - | - |
|
|
42
|
+
| Globals | [`isFinite`](https://devdocs.io/javascript/global_objects/isfinite) | Use [`Number.isFinite`](https://devdocs.io/javascript/global_objects/number/isfinite) instead. |
|
|
43
|
+
| | [`isNaN`](https://devdocs.io/javascript/global_objects/isnan) | Use [`Number.isNaN`](https://devdocs.io/javascript/global_objects/number/isnan) instead. |
|
|
44
|
+
| | [Confusing browser globals](https://github.com/facebook/create-react-app/tree/main/packages/confusing-browser-globals) | Globals such as `name` and `event` should not be used to catch typos in function parameters etc. |
|
|
45
|
+
| Properties | [`Object.hasOwn`](https://devdocs.io/javascript/global_objects/object/hasown) | Not yet supported by all browsers. |
|
|
46
|
+
| Syntax | TypeScript `public` class field modifier | Can be omitted (except for constructors of classes deriving from a class with protected constructor). |
|
|
47
|
+
| | TypeScript `private` class field modifier | Use native `#private` class fields. |
|
|
48
|
+
| | [TypeScript parameter properties](https://www.typescriptlang.org/docs/handbook/2/classes.html#parameter-properties) | Use explicit class properties. |
|
|
49
|
+
| | [Static class initialization blocks](https://www.typescriptlang.org/docs/handbook/2/classes.html#static-blocks-in-classes) | Not yet supported by all browsers. |
|
|
50
|
+
| | Module exports of [TypeScript const enumerations](https://devdocs.io/typescript~5.1/enums#enums-at-compile-time) | Not compatible with bundlers running in isolated modules mode (ESBuild). |
|
|
51
|
+
|
|
37
52
|
## Example
|
|
38
53
|
|
|
39
54
|
```js
|
package/doc/eslint/env/node.md
CHANGED
|
@@ -25,6 +25,16 @@ function node(options: EnvNodeOptions): Linter.FlatConfig[]
|
|
|
25
25
|
|
|
26
26
|
This option allows to specify banned globals, imports, object properties, and syntax constructs. See [documentation in `env.browser`](./browser.md#option-restricted) for a detailed description.
|
|
27
27
|
|
|
28
|
+
The environment `env.node` already defines the following built-in restrictions:
|
|
29
|
+
|
|
30
|
+
| Type | Name | Description |
|
|
31
|
+
| - | - | - |
|
|
32
|
+
| Globals | [`isFinite`](https://devdocs.io/javascript/global_objects/isfinite) | Use [`Number.isFinite`](https://devdocs.io/javascript/global_objects/number/isfinite) instead. |
|
|
33
|
+
| | [`isNaN`](https://devdocs.io/javascript/global_objects/isnan) | Use [`Number.isNaN`](https://devdocs.io/javascript/global_objects/number/isnan) instead. |
|
|
34
|
+
| Syntax | TypeScript `public` class field modifier | Can be omitted (except for constructors of classes deriving from a class with protected constructor). |
|
|
35
|
+
| | TypeScript `private` class field modifier | Use native `#private` class fields. |
|
|
36
|
+
| | [TypeScript parameter properties](https://www.typescriptlang.org/docs/handbook/2/classes.html#parameter-properties) | Use explicit class properties. |
|
|
37
|
+
|
|
28
38
|
## Example
|
|
29
39
|
|
|
30
40
|
```js
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package",
|
|
2
3
|
"name": "@open-xchange/linter-presets",
|
|
3
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
4
5
|
"description": "Configuration presets for ESLint and StyleLint",
|
|
5
6
|
"repository": {
|
|
6
7
|
"url": "https://gitlab.open-xchange.com/fspd/npm-packages/linter-presets"
|
|
@@ -23,8 +24,8 @@
|
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"@eslint-community/eslint-plugin-eslint-comments": "4.3.0",
|
|
26
|
-
"@eslint/compat": "1.1.
|
|
27
|
-
"@eslint/js": "9.
|
|
27
|
+
"@eslint/compat": "1.1.1",
|
|
28
|
+
"@eslint/js": "9.7.0",
|
|
28
29
|
"@stylistic/eslint-plugin": "2.3.0",
|
|
29
30
|
"@stylistic/eslint-plugin-migrate": "2.3.0",
|
|
30
31
|
"@stylistic/stylelint-config": "1.0.1",
|
|
@@ -36,14 +37,14 @@
|
|
|
36
37
|
"eslint-plugin-import": "2.29.1",
|
|
37
38
|
"eslint-plugin-jest": "28.6.0",
|
|
38
39
|
"eslint-plugin-jest-dom": "5.4.0",
|
|
39
|
-
"eslint-plugin-jsdoc": "48.
|
|
40
|
+
"eslint-plugin-jsdoc": "48.7.0",
|
|
40
41
|
"eslint-plugin-jsonc": "2.16.0",
|
|
41
42
|
"eslint-plugin-jsx-a11y": "6.9.0",
|
|
42
43
|
"eslint-plugin-jsx-expressions": "1.3.2",
|
|
43
44
|
"eslint-plugin-license-header": "0.6.1",
|
|
44
45
|
"eslint-plugin-n": "17.9.0",
|
|
45
46
|
"eslint-plugin-promise": "6.4.0",
|
|
46
|
-
"eslint-plugin-react": "7.34.
|
|
47
|
+
"eslint-plugin-react": "7.34.4",
|
|
47
48
|
"eslint-plugin-react-hooks": "4.6.2",
|
|
48
49
|
"eslint-plugin-react-hooks-static-deps": "1.0.7",
|
|
49
50
|
"eslint-plugin-react-refresh": "0.4.8",
|
|
@@ -62,13 +63,12 @@
|
|
|
62
63
|
"devDependencies": {
|
|
63
64
|
"@types/confusing-browser-globals": "1.0.3",
|
|
64
65
|
"@types/eslint__js": "8.42.3",
|
|
65
|
-
"@types/json-schema": "7.0.15",
|
|
66
66
|
"@types/picomatch": "3.0.0",
|
|
67
67
|
"@typescript-eslint/utils": "7.16.0",
|
|
68
|
-
"eslint": "9.
|
|
68
|
+
"eslint": "9.7.0",
|
|
69
69
|
"husky": "9.0.11",
|
|
70
70
|
"jest": "29.7.0",
|
|
71
|
-
"stylelint": "16.
|
|
71
|
+
"stylelint": "16.7.0",
|
|
72
72
|
"typescript": "5.5.3"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|