@open-xchange/linter-presets 1.6.0 → 1.7.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 +14 -1
- package/dist/eslint/core/base.d.ts +3 -4
- package/dist/eslint/core/base.js +95 -94
- package/dist/eslint/core/directives.d.ts +3 -3
- package/dist/eslint/core/directives.js +4 -4
- package/dist/eslint/core/js.d.ts +3 -3
- package/dist/eslint/core/js.js +4 -4
- package/dist/eslint/core/jsdoc.d.ts +3 -3
- package/dist/eslint/core/jsdoc.js +43 -42
- package/dist/eslint/core/json.d.ts +3 -4
- package/dist/eslint/core/json.js +4 -4
- package/dist/eslint/core/license.d.ts +4 -4
- package/dist/eslint/core/license.js +5 -5
- package/dist/eslint/core/markdown.d.ts +1 -1
- package/dist/eslint/core/markdown.js +1 -1
- package/dist/eslint/core/packages.d.ts +3 -4
- package/dist/eslint/core/packages.js +16 -15
- package/dist/eslint/core/promises.d.ts +3 -3
- package/dist/eslint/core/promises.js +18 -18
- package/dist/eslint/core/regexp.d.ts +3 -3
- package/dist/eslint/core/regexp.js +4 -5
- package/dist/eslint/core/stylistic.d.ts +3 -4
- package/dist/eslint/core/stylistic.js +99 -99
- package/dist/eslint/core/ts.d.ts +6 -3
- package/dist/eslint/core/ts.js +78 -72
- package/dist/eslint/core/vue.d.ts +3 -4
- package/dist/eslint/core/vue.js +4 -4
- package/dist/eslint/core/yaml.d.ts +3 -4
- package/dist/eslint/core/yaml.js +4 -4
- package/dist/eslint/env/browser.d.ts +3 -3
- package/dist/eslint/env/browser.js +18 -17
- package/dist/eslint/env/codecept.d.ts +3 -4
- package/dist/eslint/env/codecept.js +27 -26
- package/dist/eslint/env/decorators.d.ts +3 -4
- package/dist/eslint/env/decorators.js +19 -16
- package/dist/eslint/env/eslint.d.ts +3 -4
- package/dist/eslint/env/eslint.js +16 -15
- package/dist/eslint/env/jest.d.ts +3 -3
- package/dist/eslint/env/jest.js +37 -36
- package/dist/eslint/env/node.d.ts +3 -4
- package/dist/eslint/env/node.js +22 -21
- package/dist/eslint/env/project.d.ts +3 -4
- package/dist/eslint/env/project.js +25 -24
- package/dist/eslint/env/react.d.ts +3 -4
- package/dist/eslint/env/react.js +65 -64
- package/dist/eslint/env/tsconfig.d.ts +3 -4
- package/dist/eslint/env/tsconfig.js +14 -13
- package/dist/eslint/env/vitest.d.ts +3 -3
- package/dist/eslint/env/vitest.js +54 -53
- package/dist/eslint/index.d.ts +26 -21
- package/dist/eslint/index.js +15 -13
- package/dist/eslint/shared/env-utils.d.ts +11 -23
- package/dist/eslint/shared/env-utils.js +17 -31
- package/dist/eslint/shared/restricted.d.ts +3 -3
- package/dist/eslint/shared/restricted.js +12 -11
- package/dist/eslint/shared/unittest.d.ts +4 -5
- package/dist/eslint/shared/unittest.js +21 -20
- package/dist/stylelint/index.d.ts +9 -6
- package/dist/stylelint/index.js +7 -6
- package/dist/utils/resolver.d.ts +20 -10
- package/dist/utils/resolver.js +28 -10
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.js +1 -1
- package/docs/eslint/README.md +3 -30
- package/docs/stylelint/README.md +3 -30
- package/package.json +3 -3
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { defineConfig } from "@eslint/config-helpers";
|
|
2
1
|
import { flattenDeepArrays } from "../../utils/utils.js";
|
|
3
2
|
// constants ==================================================================
|
|
4
3
|
/**
|
|
@@ -67,22 +66,8 @@ export function extGlob(extensions) {
|
|
|
67
66
|
return extensions.map(ext => "**/*." + ext);
|
|
68
67
|
}
|
|
69
68
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* parameters.
|
|
73
|
-
*
|
|
74
|
-
* @param configs
|
|
75
|
-
* The configuration objects to be flattened and filtered.
|
|
76
|
-
*
|
|
77
|
-
* @returns
|
|
78
|
-
* The flattened configuration array.
|
|
79
|
-
*/
|
|
80
|
-
export function createConfigArray(...configs) {
|
|
81
|
-
return defineConfig(flattenDeepArrays(configs));
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Creates a flat configuration object with "files" and "ignores" settings from
|
|
85
|
-
* an environment's "envOptions" object.
|
|
69
|
+
* Creates a configuration entry with "files" and "ignores" settings from an
|
|
70
|
+
* environment's "envOptions" object.
|
|
86
71
|
*
|
|
87
72
|
* @param name
|
|
88
73
|
* The name of the configuration entry.
|
|
@@ -90,28 +75,28 @@ export function createConfigArray(...configs) {
|
|
|
90
75
|
* @param envOptions
|
|
91
76
|
* The environment options containing "files" and "ignores" settings.
|
|
92
77
|
*
|
|
93
|
-
* @param
|
|
94
|
-
* Properties for the
|
|
78
|
+
* @param config
|
|
79
|
+
* Properties for the configuration entry to be built. Additional "files" and
|
|
95
80
|
* "ignores" properties will be merged with the settings from "envOptions".
|
|
96
81
|
*
|
|
97
82
|
* @param rules
|
|
98
83
|
* Hard-coded rule settings to be added to the configuration.
|
|
99
84
|
*
|
|
100
85
|
* @returns
|
|
101
|
-
* The resulting
|
|
86
|
+
* The resulting configuration entry.
|
|
102
87
|
*/
|
|
103
|
-
export function createConfig(name, envOptions,
|
|
88
|
+
export function createConfig(name, envOptions, config, rules) {
|
|
104
89
|
return {
|
|
105
90
|
name,
|
|
106
|
-
...
|
|
107
|
-
files: flattenDeepArrays(envOptions.files,
|
|
108
|
-
ignores: flattenDeepArrays(envOptions.ignores,
|
|
109
|
-
rules: { ...
|
|
91
|
+
...config,
|
|
92
|
+
files: flattenDeepArrays(envOptions.files, config.files),
|
|
93
|
+
ignores: flattenDeepArrays(envOptions.ignores, config.ignores),
|
|
94
|
+
rules: { ...config.rules, ...rules },
|
|
110
95
|
};
|
|
111
96
|
}
|
|
112
97
|
/**
|
|
113
|
-
* Creates a
|
|
114
|
-
*
|
|
98
|
+
* Creates a configuration entry with "files", "ignores", and "rules" settings
|
|
99
|
+
* from an environment's "envOptions" object.
|
|
115
100
|
*
|
|
116
101
|
* @param name
|
|
117
102
|
* The name of the configuration entry.
|
|
@@ -126,7 +111,7 @@ export function createConfig(name, envOptions, flatConfig, rules) {
|
|
|
126
111
|
* allow to override them.
|
|
127
112
|
*
|
|
128
113
|
* @returns
|
|
129
|
-
* The resulting
|
|
114
|
+
* The resulting configuration entry, if the environment options contain
|
|
130
115
|
* custom rule settings, otherwise `undefined`.
|
|
131
116
|
*/
|
|
132
117
|
export function customRules(name, envOptions, rules) {
|
|
@@ -145,9 +130,10 @@ export function customRules(name, envOptions, rules) {
|
|
|
145
130
|
* @returns
|
|
146
131
|
* The fixed configuration options.
|
|
147
132
|
*/
|
|
148
|
-
export function fixMissingFilesOption(configs) {
|
|
149
|
-
const
|
|
150
|
-
|
|
133
|
+
export function fixMissingFilesOption(...configs) {
|
|
134
|
+
const flatConfigs = flattenDeepArrays(configs);
|
|
135
|
+
const files = flatConfigs.find(config => !!config.files)?.files;
|
|
136
|
+
return files ? flatConfigs.map(config => (!config.files && (config.languageOptions || config.rules)) ? { ...config, files } : config) : flatConfigs;
|
|
151
137
|
}
|
|
152
138
|
/**
|
|
153
139
|
* Converts all warnings in the passed rule options to errors.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Linter } from "eslint";
|
|
2
|
-
import type { EnvFilesOptions, EnvBaseOptions } from "./env-utils.js";
|
|
2
|
+
import type { ConfigWithExtendsArg, EnvFilesOptions, EnvBaseOptions } from "./env-utils.js";
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for a single banned global or import.
|
|
5
5
|
*/
|
|
@@ -85,6 +85,6 @@ export declare function builtinRestrictedRules(): Linter.RulesRecord;
|
|
|
85
85
|
* The fixed restricted items provided by the environment preset.
|
|
86
86
|
*
|
|
87
87
|
* @returns
|
|
88
|
-
* The
|
|
88
|
+
* The configuration entries needed to forbid the restricted items.
|
|
89
89
|
*/
|
|
90
|
-
export declare function restrictedRulesConfig(baseName: string, envOptions: EnvRestrictedOptions, fixed?: EnvRestrictedItems):
|
|
90
|
+
export declare function restrictedRulesConfig(baseName: string, envOptions: EnvRestrictedOptions, fixed?: EnvRestrictedItems): ConfigWithExtendsArg;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { flattenDeepArrays } from "../../utils/utils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { createConfig } from "./env-utils.js";
|
|
3
3
|
// functions ==================================================================
|
|
4
4
|
/**
|
|
5
5
|
* Creates a rules record for all restricted items.
|
|
@@ -77,20 +77,21 @@ export function builtinRestrictedRules() {
|
|
|
77
77
|
* The fixed restricted items provided by the environment preset.
|
|
78
78
|
*
|
|
79
79
|
* @returns
|
|
80
|
-
* The
|
|
80
|
+
* The configuration entries needed to forbid the restricted items.
|
|
81
81
|
*/
|
|
82
82
|
export function restrictedRulesConfig(baseName, envOptions, fixed) {
|
|
83
83
|
const { restricted } = envOptions;
|
|
84
84
|
// restricted items for all files in the environment
|
|
85
85
|
const items = mergeRestrictedItems(fixed, restricted);
|
|
86
86
|
// generate the configuration objects
|
|
87
|
-
return
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
return [
|
|
88
|
+
// base rules for all files in the environment
|
|
89
|
+
createConfig(baseName, envOptions, {
|
|
90
|
+
rules: createRulesRecord(key => items[key]),
|
|
91
|
+
}),
|
|
92
|
+
// generate the override entries (join with base items)
|
|
93
|
+
restricted?.overrides?.map((override, index) => createConfig(`${baseName}-override-${index}`, override, {
|
|
94
|
+
rules: createRulesRecord(key => flattenDeepArrays(items[key], override[key])),
|
|
95
|
+
})),
|
|
96
|
+
];
|
|
96
97
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type EnvBaseOptions } from "./env-utils.js";
|
|
1
|
+
import type { ConfigWithExtendsArg, EnvBaseOptions } from "./env-utils.js";
|
|
3
2
|
/**
|
|
4
3
|
* Shared options for environment presets for unit tests.
|
|
5
4
|
*/
|
|
@@ -27,7 +26,7 @@ export interface EnvUnitTestOptions extends EnvBaseOptions {
|
|
|
27
26
|
testingLib?: "angular" | "dom" | "marko" | "react" | "vue";
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
30
|
-
* Conditionally creates
|
|
29
|
+
* Conditionally creates configuration entries for the ESLint plugins
|
|
31
30
|
* `eslint-plugin-jest-dom` and `eslint-plugin-testing-library`.
|
|
32
31
|
*
|
|
33
32
|
* @param baseName
|
|
@@ -37,6 +36,6 @@ export interface EnvUnitTestOptions extends EnvBaseOptions {
|
|
|
37
36
|
* The configuration options for the unit test environment.
|
|
38
37
|
*
|
|
39
38
|
* @returns
|
|
40
|
-
* The resulting
|
|
39
|
+
* The resulting configuration entries.
|
|
41
40
|
*/
|
|
42
|
-
export declare function createUnitTestPluginConfigs(baseName: string, envOptions: EnvUnitTestOptions):
|
|
41
|
+
export declare function createUnitTestPluginConfigs(baseName: string, envOptions: EnvUnitTestOptions): ConfigWithExtendsArg;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import extendedPlugin from "eslint-plugin-jest-extended";
|
|
2
2
|
import jestDomPlugin from "eslint-plugin-jest-dom";
|
|
3
3
|
import testingLibraryPlugin from "eslint-plugin-testing-library";
|
|
4
|
-
import {
|
|
4
|
+
import { createConfig } from "./env-utils.js";
|
|
5
5
|
// functions ==================================================================
|
|
6
6
|
/**
|
|
7
|
-
* Conditionally creates
|
|
7
|
+
* Conditionally creates configuration entries for the ESLint plugins
|
|
8
8
|
* `eslint-plugin-jest-dom` and `eslint-plugin-testing-library`.
|
|
9
9
|
*
|
|
10
10
|
* @param baseName
|
|
@@ -14,24 +14,25 @@ import { createConfigArray, createConfig } from "./env-utils.js";
|
|
|
14
14
|
* The configuration options for the unit test environment.
|
|
15
15
|
*
|
|
16
16
|
* @returns
|
|
17
|
-
* The resulting
|
|
17
|
+
* The resulting configuration entries.
|
|
18
18
|
*/
|
|
19
19
|
export function createUnitTestPluginConfigs(baseName, envOptions) {
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
20
|
+
return [
|
|
21
|
+
// "jest-extended" plugin (config "flat/recommended" is empty)
|
|
22
|
+
envOptions.jestExtended && createConfig(`${baseName}:extended`, envOptions, extendedPlugin.configs["flat/all"]),
|
|
23
|
+
// "jest-dom" plugin
|
|
24
|
+
envOptions.jestDom && createConfig(`${baseName}:jest-dom`, envOptions, jestDomPlugin.configs["flat/recommended"]),
|
|
25
|
+
// "testing-library" plugin
|
|
26
|
+
envOptions.testingLib && createConfig(`${baseName}:testing-library`, envOptions, {
|
|
27
|
+
// register rule implementations of the plugins
|
|
28
|
+
plugins: {
|
|
29
|
+
"testing-library": testingLibraryPlugin,
|
|
30
|
+
},
|
|
31
|
+
// recommended rules
|
|
32
|
+
rules: {
|
|
33
|
+
...testingLibraryPlugin.configs["flat/react"].rules,
|
|
34
|
+
"testing-library/no-node-access": ["error", { allowContainerFirstChild: true }],
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
];
|
|
37
38
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Config } from "stylelint";
|
|
2
|
-
export * from "../utils/resolver.js";
|
|
3
2
|
/**
|
|
4
3
|
* Configuration options for StyleLint code style rules.
|
|
5
4
|
*/
|
|
@@ -20,15 +19,19 @@ export interface StylisticOptions {
|
|
|
20
19
|
/**
|
|
21
20
|
* Configuration options for linting the entire project with StyleLint.
|
|
22
21
|
*/
|
|
23
|
-
export interface
|
|
22
|
+
export interface ProjectOptions {
|
|
23
|
+
/**
|
|
24
|
+
* The URL of the project root containing the StyleLint configuration file.
|
|
25
|
+
* Should usually be set to `import.meta.url`.
|
|
26
|
+
*/
|
|
27
|
+
root: string;
|
|
24
28
|
/**
|
|
25
29
|
* Glob patterns with all files and folders to be ignored by StyleLint.
|
|
26
30
|
*/
|
|
27
31
|
ignores?: string[];
|
|
28
32
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* path to an absolute path.
|
|
33
|
+
* Path to the template file containing the license header to be used in
|
|
34
|
+
* all source files. May be a path relative to the project root.
|
|
32
35
|
*/
|
|
33
36
|
license?: string;
|
|
34
37
|
/**
|
|
@@ -50,4 +53,4 @@ export interface ConfigureOptions {
|
|
|
50
53
|
* @returns
|
|
51
54
|
* The configuration object to be exported from `stylelint.config.js`.
|
|
52
55
|
*/
|
|
53
|
-
export declare function defineConfig(options
|
|
56
|
+
export declare function defineConfig(options: ProjectOptions): Config;
|
package/dist/stylelint/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export * from "../utils/resolver.js";
|
|
1
|
+
import { PathResolver } from "../utils/resolver.js";
|
|
3
2
|
// functions ==================================================================
|
|
4
3
|
/**
|
|
5
4
|
* Generates a StyleLint configuration object targeting the source files in the
|
|
@@ -18,16 +17,16 @@ export function defineConfig(options) {
|
|
|
18
17
|
"coverage", // Vitest
|
|
19
18
|
".nuxt", // NuxtJS
|
|
20
19
|
".output", // NuxtJS
|
|
21
|
-
...(options
|
|
20
|
+
...(options.ignores ?? []),
|
|
22
21
|
];
|
|
23
22
|
// resolve stylistic configuration options
|
|
24
23
|
const stylistic = {
|
|
25
24
|
indent: 4,
|
|
26
25
|
quotes: "double",
|
|
27
|
-
...options
|
|
26
|
+
...options.stylistic,
|
|
28
27
|
};
|
|
29
28
|
const rules = { base: {}, scss: {}, less: {} };
|
|
30
|
-
for (const [rule, value] of Object.entries(options
|
|
29
|
+
for (const [rule, value] of Object.entries(options.rules ?? {})) {
|
|
31
30
|
const key = rule.split("/")[0];
|
|
32
31
|
(rules[key] ?? rules.base)[rule] = value;
|
|
33
32
|
}
|
|
@@ -37,6 +36,8 @@ export function defineConfig(options) {
|
|
|
37
36
|
"scss/double-slash-comment-empty-line-before": null,
|
|
38
37
|
...rules.scss,
|
|
39
38
|
};
|
|
39
|
+
// the resolver for relative file paths
|
|
40
|
+
const resolver = new PathResolver(options.root);
|
|
40
41
|
return {
|
|
41
42
|
// ignore certain files and folders
|
|
42
43
|
ignoreFiles,
|
|
@@ -73,7 +74,7 @@ export function defineConfig(options) {
|
|
|
73
74
|
"rule-empty-line-before": null,
|
|
74
75
|
"shorthand-property-no-redundant-values": [true, { ignore: ["four-into-three-edge-values"] }],
|
|
75
76
|
// license-header plugin
|
|
76
|
-
...(options
|
|
77
|
+
...(options.license ? { "plugin/license-header": [true, { license: resolver.path(options.license) }] } : null),
|
|
77
78
|
// stylistic plugin
|
|
78
79
|
"@stylistic/declaration-colon-newline-after": null,
|
|
79
80
|
"@stylistic/indentation": [stylistic.indent, { ignore: ["inside-parens"] }],
|
package/dist/utils/resolver.d.ts
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
export type FileResolveFn = (file: string) => string;
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
* base URL of a script file.
|
|
5
|
-
*
|
|
6
|
-
* @param url
|
|
7
|
-
* The base URL of the calling script, usually `import.meta.url`.
|
|
8
|
-
*
|
|
9
|
-
* @returns
|
|
10
|
-
* A function that converts relative file paths to absolute file paths.
|
|
2
|
+
* A resolver for file paths relative to a base URL.
|
|
11
3
|
*/
|
|
12
|
-
export declare
|
|
4
|
+
export declare class PathResolver {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(url: string);
|
|
7
|
+
/**
|
|
8
|
+
* @returns
|
|
9
|
+
* The directory path of the URL passed to the constructor.
|
|
10
|
+
*/
|
|
11
|
+
get root(): string;
|
|
12
|
+
/**
|
|
13
|
+
* Converts a file path relative to "root" to an absolute file path.
|
|
14
|
+
*
|
|
15
|
+
* @param file
|
|
16
|
+
* The file path to be converted.
|
|
17
|
+
*
|
|
18
|
+
* @returns
|
|
19
|
+
* The absolute file path.
|
|
20
|
+
*/
|
|
21
|
+
path(file: string): string;
|
|
22
|
+
}
|
package/dist/utils/resolver.js
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
1
2
|
import { URL, fileURLToPath } from "node:url";
|
|
2
3
|
// functions ==================================================================
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
* base URL of a script file.
|
|
6
|
-
*
|
|
7
|
-
* @param url
|
|
8
|
-
* The base URL of the calling script, usually `import.meta.url`.
|
|
9
|
-
*
|
|
10
|
-
* @returns
|
|
11
|
-
* A function that converts relative file paths to absolute file paths.
|
|
5
|
+
* A resolver for file paths relative to a base URL.
|
|
12
6
|
*/
|
|
13
|
-
export
|
|
14
|
-
|
|
7
|
+
export class PathResolver {
|
|
8
|
+
#url;
|
|
9
|
+
#root;
|
|
10
|
+
constructor(url) {
|
|
11
|
+
this.#url = url;
|
|
12
|
+
this.#root = dirname(fileURLToPath(url));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @returns
|
|
16
|
+
* The directory path of the URL passed to the constructor.
|
|
17
|
+
*/
|
|
18
|
+
get root() {
|
|
19
|
+
return this.#root;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Converts a file path relative to "root" to an absolute file path.
|
|
23
|
+
*
|
|
24
|
+
* @param file
|
|
25
|
+
* The file path to be converted.
|
|
26
|
+
*
|
|
27
|
+
* @returns
|
|
28
|
+
* The absolute file path.
|
|
29
|
+
*/
|
|
30
|
+
path(file) {
|
|
31
|
+
return fileURLToPath(new URL(file, this.#url));
|
|
32
|
+
}
|
|
15
33
|
}
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type DeepOptArray<T> = T | false | null | undefined | ReadonlyArray<DeepO
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function yieldDeepArrays<T>(...arrays: Array<DeepOptArray<T>>): IterableIterator<T>;
|
|
19
19
|
/**
|
|
20
|
-
* Returns a flat array all truthy elements of all deeply nested arrays.
|
|
20
|
+
* Returns a flat array with all truthy elements of all deeply nested arrays.
|
|
21
21
|
*
|
|
22
22
|
* @template T
|
|
23
23
|
* The element type of the array.
|
package/dist/utils/utils.js
CHANGED
|
@@ -24,7 +24,7 @@ export function* yieldDeepArrays(...arrays) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Returns a flat array all truthy elements of all deeply nested arrays.
|
|
27
|
+
* Returns a flat array with all truthy elements of all deeply nested arrays.
|
|
28
28
|
*
|
|
29
29
|
* @template T
|
|
30
30
|
* The element type of the array.
|
package/docs/eslint/README.md
CHANGED
|
@@ -4,31 +4,6 @@ The module `eslint` provides a `defineConfig` function to create a project-wide
|
|
|
4
4
|
|
|
5
5
|
## Functions
|
|
6
6
|
|
|
7
|
-
### Function `createResolver`
|
|
8
|
-
|
|
9
|
-
Creates and returns a function that will convert relative file paths to absolute file paths. Intended to be used with the base URL of the calling script, usually `import.meta.url`.
|
|
10
|
-
|
|
11
|
-
#### `createResolver` Signature
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
function createResolver(url: string): (file: string) => string;
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
#### `createResolver` Example
|
|
18
|
-
|
|
19
|
-
```js
|
|
20
|
-
// eslint.config.ts
|
|
21
|
-
import { createResolver, defineConfig } from "@open-xchange/linter-presets/eslint";
|
|
22
|
-
|
|
23
|
-
const resolve = createResolver(import.meta.url);
|
|
24
|
-
|
|
25
|
-
export default defineConfig({
|
|
26
|
-
// ...
|
|
27
|
-
license: resolve("./license.txt"),
|
|
28
|
-
// ...
|
|
29
|
-
});
|
|
30
|
-
```
|
|
31
|
-
|
|
32
7
|
### Function `defineConfig`
|
|
33
8
|
|
|
34
9
|
Generates standard configuration targeting the source files in the entire project, and allows to add more custom configuration entries. Internally, various ESLint plugins will be included and configured to use their recommended rule sets.
|
|
@@ -53,7 +28,7 @@ Generates standard configuration targeting the source files in the entire projec
|
|
|
53
28
|
#### `defineConfig` Signature
|
|
54
29
|
|
|
55
30
|
```ts
|
|
56
|
-
function defineConfig(options:
|
|
31
|
+
function defineConfig(options: ProjectOptions, ...configs: ConfigWithExtendsArg[]): Linter.Config[];
|
|
57
32
|
```
|
|
58
33
|
|
|
59
34
|
After the mandatory `options` parameters, the function can take multiple custom configuration objects or arrays, for example environment configuration presets (see below).
|
|
@@ -96,14 +71,12 @@ This package defines ignore globs for the following files and directories:
|
|
|
96
71
|
|
|
97
72
|
```ts
|
|
98
73
|
// eslint.config.ts
|
|
99
|
-
import {
|
|
100
|
-
|
|
101
|
-
const resolve = createResolver(import.meta.url);
|
|
74
|
+
import { defineConfig } from "@open-xchange/linter-presets/eslint";
|
|
102
75
|
|
|
103
76
|
export default defineConfig({
|
|
104
77
|
ignores: ["external/**/*.yaml"],
|
|
105
78
|
language: { ecmaVersion: 2024, sourceType: "commonjs" },
|
|
106
|
-
license:
|
|
79
|
+
license: "./license.txt",
|
|
107
80
|
stylistic: { quotes: "single", semi: "never" },
|
|
108
81
|
});
|
|
109
82
|
```
|
package/docs/stylelint/README.md
CHANGED
|
@@ -4,31 +4,6 @@ The module `stylelint` provides a `defineConfig` function for project-wide Style
|
|
|
4
4
|
|
|
5
5
|
## Functions
|
|
6
6
|
|
|
7
|
-
### Function `createResolver`
|
|
8
|
-
|
|
9
|
-
Creates and returns a function that will convert relative file paths to absolute file paths. Intended to be used with the base URL of the calling script, usually `import.meta.url`.
|
|
10
|
-
|
|
11
|
-
#### `createResolver` Signature
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
function createResolver(url: string): (file: string) => string;
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
#### `createResolver` Example
|
|
18
|
-
|
|
19
|
-
```js
|
|
20
|
-
// stylelint.config.js
|
|
21
|
-
import { createResolver, defineConfig } from "@open-xchange/linter-presets/stylelint";
|
|
22
|
-
|
|
23
|
-
const resolve = createResolver(import.meta.url);
|
|
24
|
-
|
|
25
|
-
export default defineConfig({
|
|
26
|
-
// ...
|
|
27
|
-
license: resolve("./license.txt"),
|
|
28
|
-
// ...
|
|
29
|
-
});
|
|
30
|
-
```
|
|
31
|
-
|
|
32
7
|
### Function `defineConfig`
|
|
33
8
|
|
|
34
9
|
Generates standard configuration targeting the source files in the entire project. Internally, various StyleLint plugins will be included and configured to use their recommended rule sets.
|
|
@@ -45,7 +20,7 @@ Generates standard configuration targeting the source files in the entire projec
|
|
|
45
20
|
```ts
|
|
46
21
|
import type { Config } from "stylelint";
|
|
47
22
|
|
|
48
|
-
function defineConfig(options?:
|
|
23
|
+
function defineConfig(options?: ProjectOptions): Config;
|
|
49
24
|
```
|
|
50
25
|
|
|
51
26
|
#### `defineConfig` Options
|
|
@@ -72,13 +47,11 @@ This package defines ignore globs for the following files and directories:
|
|
|
72
47
|
|
|
73
48
|
```ts
|
|
74
49
|
// stylelint.config.js
|
|
75
|
-
import {
|
|
76
|
-
|
|
77
|
-
const resolve = createResolver(import.meta.url);
|
|
50
|
+
import { defineConfig } from "@open-xchange/linter-presets/stylelint";
|
|
78
51
|
|
|
79
52
|
export default defineConfig({
|
|
80
53
|
ignores: ["external/**/*.scss"],
|
|
81
|
-
license:
|
|
54
|
+
license: "./license.txt",
|
|
82
55
|
stylistic: { indent: 2, quotes: "single" },
|
|
83
56
|
});
|
|
84
57
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-xchange/linter-presets",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Configuration presets for ESLint and StyleLint",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@eslint/config-helpers": "^0.3.0",
|
|
40
40
|
"@eslint/js": "^9.31.0",
|
|
41
41
|
"@eslint/markdown": "^7.0.0",
|
|
42
|
-
"@stylistic/eslint-plugin": "^5.
|
|
42
|
+
"@stylistic/eslint-plugin": "^5.2.0",
|
|
43
43
|
"@stylistic/eslint-plugin-migrate": "^4.4.1",
|
|
44
44
|
"@stylistic/stylelint-config": "^2.0.0",
|
|
45
45
|
"@stylistic/stylelint-plugin": "^3.1.3",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"eslint-plugin-jest": "^29.0.1",
|
|
54
54
|
"eslint-plugin-jest-dom": "^5.5.0",
|
|
55
55
|
"eslint-plugin-jest-extended": "^3.0.0",
|
|
56
|
-
"eslint-plugin-jsdoc": "^51.4.
|
|
56
|
+
"eslint-plugin-jsdoc": "^51.4.1",
|
|
57
57
|
"eslint-plugin-jsonc": "^2.20.1",
|
|
58
58
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
59
59
|
"eslint-plugin-license-header": "^0.8.0",
|