@open-xchange/linter-presets 1.31.1 → 1.32.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 +16 -1
- package/dist/eslint/index.d.mts +0 -40
- package/dist/eslint/index.d.mts.map +1 -1
- package/dist/eslint/index.mjs +61 -73
- package/dist/eslint/index.mjs.map +1 -1
- package/dist/{resolver-CKKbaGEf.mjs → resolver-COtuVv5w.mjs} +2 -3
- package/dist/{resolver-CKKbaGEf.mjs.map → resolver-COtuVv5w.mjs.map} +1 -1
- package/dist/stylelint/index.d.mts +5 -4
- package/dist/stylelint/index.d.mts.map +1 -1
- package/dist/stylelint/index.mjs +76 -28
- package/dist/stylelint/index.mjs.map +1 -1
- package/docs/stylelint/README.md +1 -1
- package/package.json +21 -22
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dirname } from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
|
|
3
|
+
// src/utils/resolver.ts
|
|
4
4
|
/**
|
|
5
5
|
* A resolver for file paths relative to a base URL.
|
|
6
6
|
*/
|
|
@@ -33,7 +33,6 @@ var PathResolver = class {
|
|
|
33
33
|
return fileURLToPath(new URL(file, this.#url));
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
//#endregion
|
|
37
36
|
export { PathResolver as t };
|
|
38
37
|
|
|
39
|
-
//# sourceMappingURL=resolver-
|
|
38
|
+
//# sourceMappingURL=resolver-COtuVv5w.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver-
|
|
1
|
+
{"version":3,"file":"resolver-COtuVv5w.mjs","names":[],"sources":["../src/utils/resolver.ts"],"sourcesContent":["\nimport { dirname } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n// class PathResolver =========================================================\n\n/**\n * A resolver for file paths relative to a base URL.\n */\nexport class PathResolver {\n\n readonly #url: string\n readonly #root: string\n\n constructor(url: string) {\n this.#url = url\n this.#root = dirname(fileURLToPath(url))\n }\n\n /**\n * Returns the directory path of the URL passed to the constructor.\n *\n * @returns\n * The directory path of the URL passed to the constructor.\n */\n get root(): string {\n return this.#root\n }\n\n /**\n * Converts a file path relative to 'root' to an absolute file path.\n *\n * @param file\n * The file path to be converted.\n *\n * @returns\n * The absolute file path.\n */\n path(file: string): string {\n return fileURLToPath(new URL(file, this.#url))\n }\n}\n"],"mappings":";;;;;;AASA,IAAa,eAAb,MAA0B;CAExB;CACA;CAEA,YAAY,KAAa;EACvB,KAAK,OAAO;EACZ,KAAK,QAAQ,QAAQ,cAAc,GAAG,CAAC;CACzC;;;;;;;CAQA,IAAI,OAAe;EACjB,OAAO,KAAK;CACd;;;;;;;;;;CAWA,KAAK,MAAsB;EACzB,OAAO,cAAc,IAAI,IAAI,MAAM,KAAK,IAAI,CAAC;CAC/C;AACF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Config } from "stylelint";
|
|
2
|
-
//#region src/stylelint/index.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Configuration for multiple rules.
|
|
5
4
|
*/
|
|
@@ -72,8 +71,11 @@ export interface ProjectOptions {
|
|
|
72
71
|
vue?: VueOptions;
|
|
73
72
|
/**
|
|
74
73
|
* Additional linter rules to be added to the global configuration. Rule
|
|
75
|
-
* names starting with `scss/` or `less/`
|
|
76
|
-
*
|
|
74
|
+
* names starting with `scss/` or `less/` (also `@stylistic/scss/` or
|
|
75
|
+
* `@stylistic/less/`) will automatically be assigned to the respective
|
|
76
|
+
* language override configuration. Rules of the `@stylistic` plugin without
|
|
77
|
+
* syntax namespace (e.g. `@stylistic/indentation`) will be applied to SCSS
|
|
78
|
+
* and Less files too.
|
|
77
79
|
*/
|
|
78
80
|
rules?: RuleRecord;
|
|
79
81
|
}
|
|
@@ -89,5 +91,4 @@ export interface ProjectOptions {
|
|
|
89
91
|
* file (e.g. `stylelint.config.ts`).
|
|
90
92
|
*/
|
|
91
93
|
export declare function defineConfig(options: ProjectOptions): Config;
|
|
92
|
-
//#endregion
|
|
93
94
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/stylelint/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/stylelint/index.ts"],"mappings":";;;;YAeY,aAAa,YAAY;;;;iBAOpB;;;;;;EAOf;;;;;;;EAQA;;;;;iBAQe;;;;;;EAOf;;;;;EAMA,QAAQ;;;;;iBAQO;;;;;EAMf;;;;;EAMA;;;;;EAMA;;;;;EAMA;;;;EAKA,YAAY;;;;EAKZ,MAAM;;;;;;;;;EAUN,QAAQ;;;;;;;;;;;;;wBAmDM,aAAa,SAAS,iBAAiB"}
|
package/dist/stylelint/index.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { t as PathResolver } from "../resolver-
|
|
1
|
+
import { t as PathResolver } from "../resolver-COtuVv5w.mjs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
+
import standardLessConfig from "stylelint-config-standard-less";
|
|
4
|
+
import standardScssConfig from "stylelint-config-standard-scss";
|
|
5
|
+
import { rules } from "@stylistic/stylelint-config";
|
|
3
6
|
import { readFile } from "node:fs/promises";
|
|
4
7
|
import stylelint from "stylelint";
|
|
5
|
-
|
|
8
|
+
// src/stylelint/rules/license-header.ts
|
|
6
9
|
const { createPlugin, utils: { ruleMessages, validateOptions, report } } = stylelint;
|
|
7
10
|
const ruleName = "license-header/header";
|
|
8
11
|
const messages = ruleMessages(ruleName, {
|
|
@@ -73,8 +76,7 @@ var license_header_default = createPlugin(ruleName, Object.assign(ruleFunc, {
|
|
|
73
76
|
ruleName,
|
|
74
77
|
messages
|
|
75
78
|
}));
|
|
76
|
-
|
|
77
|
-
//#region src/stylelint/package-utils.ts
|
|
79
|
+
// src/stylelint/package-utils.ts
|
|
78
80
|
/**
|
|
79
81
|
* Resolves the name of an extension or plugin package to the absolute path of
|
|
80
82
|
* its entry file, as seen from this package.
|
|
@@ -97,8 +99,29 @@ var license_header_default = createPlugin(ruleName, Object.assign(ruleFunc, {
|
|
|
97
99
|
function resolvePackage(name) {
|
|
98
100
|
return fileURLToPath(import.meta.resolve(name));
|
|
99
101
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
// src/stylelint/index.ts
|
|
103
|
+
const STYLISTIC_RULE_RE = /^@stylistic\/([^/]+)$/;
|
|
104
|
+
const SCSS_DISABLED_RULES = { "value-no-invalid": null };
|
|
105
|
+
const LESS_DISABLED_RULES = {
|
|
106
|
+
"selector-no-invalid": null,
|
|
107
|
+
"selector-no-unmatchable": null,
|
|
108
|
+
"value-no-invalid": null
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Adds a namespace prefix to the names of all passed rules.
|
|
112
|
+
*
|
|
113
|
+
* @param rules
|
|
114
|
+
* The rule settings to be prefixed.
|
|
115
|
+
*
|
|
116
|
+
* @param prefix
|
|
117
|
+
* The namespace prefix for all rule names, without trailing slash.
|
|
118
|
+
*
|
|
119
|
+
* @returns
|
|
120
|
+
* The rule settings with prefixed rule names.
|
|
121
|
+
*/
|
|
122
|
+
function prefixRules(rules, prefix) {
|
|
123
|
+
return Object.fromEntries(Object.entries(rules).map(([name, rule]) => [`${prefix}/${name}`, rule]));
|
|
124
|
+
}
|
|
102
125
|
/**
|
|
103
126
|
* Generates a StyleLint configuration object targeting the source files in the
|
|
104
127
|
* entire project.
|
|
@@ -126,14 +149,42 @@ function defineConfig(options) {
|
|
|
126
149
|
...options.stylistic
|
|
127
150
|
};
|
|
128
151
|
const resolver = new PathResolver(options.root);
|
|
152
|
+
const standardScss = [
|
|
153
|
+
resolvePackage("stylelint-config-recommended-scss"),
|
|
154
|
+
{ rules: standardScssConfig.rules },
|
|
155
|
+
{ rules: SCSS_DISABLED_RULES }
|
|
156
|
+
];
|
|
129
157
|
const extensions = {
|
|
130
158
|
base: [resolvePackage("stylelint-config-standard"), resolvePackage("@stylistic/stylelint-config")],
|
|
131
|
-
scss:
|
|
132
|
-
less: [
|
|
133
|
-
|
|
159
|
+
scss: standardScss,
|
|
160
|
+
less: [
|
|
161
|
+
resolvePackage("stylelint-config-recommended-less"),
|
|
162
|
+
{ rules: standardLessConfig.rules },
|
|
163
|
+
{ rules: LESS_DISABLED_RULES }
|
|
164
|
+
],
|
|
165
|
+
vue: options.vue?.lang === "scss" ? [
|
|
166
|
+
resolvePackage("stylelint-config-standard-vue"),
|
|
167
|
+
...standardScss,
|
|
168
|
+
resolvePackage("stylelint-config-recommended-vue/scss"),
|
|
169
|
+
{ rules: prefixRules(rules, "@stylistic/scss") }
|
|
170
|
+
] : [resolvePackage("stylelint-config-standard-vue")]
|
|
134
171
|
};
|
|
135
172
|
if (options.tailwind) extensions.base.push(resolvePackage("stylelint-config-tailwindcss"));
|
|
136
|
-
const
|
|
173
|
+
const stylisticRules = {
|
|
174
|
+
"declaration-block-single-line-max-declarations": null,
|
|
175
|
+
"declaration-colon-newline-after": null,
|
|
176
|
+
indentation: [stylistic.indent, { ignore: ["inside-parens"] }],
|
|
177
|
+
"max-line-length": null,
|
|
178
|
+
"no-empty-first-line": null,
|
|
179
|
+
"selector-list-comma-newline-after": null,
|
|
180
|
+
"string-quotes": stylistic.quotes === "off" ? null : [stylistic.quotes, { avoidEscape: true }]
|
|
181
|
+
};
|
|
182
|
+
const customRules = Object.entries(options.rules ?? {});
|
|
183
|
+
for (const [name, rule] of customRules) {
|
|
184
|
+
const match = STYLISTIC_RULE_RE.exec(name);
|
|
185
|
+
if (match) stylisticRules[match[1]] = rule;
|
|
186
|
+
}
|
|
187
|
+
const rules$1 = {
|
|
137
188
|
base: {
|
|
138
189
|
"at-rule-empty-line-before": null,
|
|
139
190
|
"color-function-notation": ["modern", { ignore: ["with-var-inside"] }],
|
|
@@ -141,7 +192,6 @@ function defineConfig(options) {
|
|
|
141
192
|
"comment-empty-line-before": null,
|
|
142
193
|
"custom-property-empty-line-before": null,
|
|
143
194
|
"declaration-block-no-redundant-longhand-properties": [true, { ignoreShorthands: ["inset"] }],
|
|
144
|
-
"declaration-block-single-line-max-declarations": null,
|
|
145
195
|
"declaration-empty-line-before": null,
|
|
146
196
|
"function-url-no-scheme-relative": true,
|
|
147
197
|
"function-url-scheme-allowed-list": ["data"],
|
|
@@ -150,39 +200,38 @@ function defineConfig(options) {
|
|
|
150
200
|
"no-unknown-animations": true,
|
|
151
201
|
"rule-empty-line-before": null,
|
|
152
202
|
"shorthand-property-no-redundant-values": [true, { ignore: ["four-into-three-edge-values"] }],
|
|
153
|
-
"@stylistic
|
|
154
|
-
"@stylistic/indentation": [stylistic.indent, { ignore: ["inside-parens"] }],
|
|
155
|
-
"@stylistic/max-line-length": null,
|
|
156
|
-
"@stylistic/no-empty-first-line": null,
|
|
157
|
-
"@stylistic/selector-list-comma-newline-after": null,
|
|
158
|
-
"@stylistic/string-quotes": stylistic.quotes === "off" ? null : [stylistic.quotes, { avoidEscape: true }]
|
|
203
|
+
...prefixRules(stylisticRules, "@stylistic")
|
|
159
204
|
},
|
|
160
205
|
scss: {
|
|
161
206
|
"scss/dollar-variable-empty-line-before": null,
|
|
162
|
-
"scss/double-slash-comment-empty-line-before": null
|
|
207
|
+
"scss/double-slash-comment-empty-line-before": null,
|
|
208
|
+
...prefixRules(stylisticRules, "@stylistic/scss")
|
|
163
209
|
},
|
|
164
|
-
less: {},
|
|
165
|
-
vue: {
|
|
210
|
+
less: { ...prefixRules(stylisticRules, "@stylistic/less") },
|
|
211
|
+
vue: {
|
|
212
|
+
...options.vue?.lang === "scss" ? prefixRules(stylisticRules, "@stylistic/scss") : void 0,
|
|
213
|
+
...options.vue?.rules
|
|
214
|
+
}
|
|
166
215
|
};
|
|
167
|
-
|
|
168
|
-
const key = name.split("/")[0];
|
|
169
|
-
(rules[key] ?? rules.base)[name] = rule;
|
|
216
|
+
for (const [name, rule] of customRules) if (!STYLISTIC_RULE_RE.test(name)) {
|
|
217
|
+
const key = name.replace(/^@stylistic\//, "").split("/")[0];
|
|
218
|
+
(rules$1[key] ?? rules$1.base)[name] = rule;
|
|
170
219
|
}
|
|
171
220
|
const overrides = [
|
|
172
221
|
{
|
|
173
222
|
files: ["**/*.scss"],
|
|
174
223
|
extends: extensions.scss,
|
|
175
|
-
rules: rules.scss
|
|
224
|
+
rules: rules$1.scss
|
|
176
225
|
},
|
|
177
226
|
{
|
|
178
227
|
files: ["**/*.less"],
|
|
179
228
|
extends: extensions.less,
|
|
180
|
-
rules: rules.less
|
|
229
|
+
rules: rules$1.less
|
|
181
230
|
},
|
|
182
231
|
{
|
|
183
232
|
files: ["**/*.vue"],
|
|
184
233
|
extends: extensions.vue,
|
|
185
|
-
rules: rules.vue
|
|
234
|
+
rules: rules$1.vue
|
|
186
235
|
}
|
|
187
236
|
];
|
|
188
237
|
if (options.license) overrides.push({
|
|
@@ -197,11 +246,10 @@ function defineConfig(options) {
|
|
|
197
246
|
reportNeedlessDisables: true,
|
|
198
247
|
reportUnscopedDisables: true,
|
|
199
248
|
extends: extensions.base,
|
|
200
|
-
rules: rules.base,
|
|
249
|
+
rules: rules$1.base,
|
|
201
250
|
overrides
|
|
202
251
|
};
|
|
203
252
|
}
|
|
204
|
-
//#endregion
|
|
205
253
|
export { defineConfig };
|
|
206
254
|
|
|
207
255
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["licensePlugin"],"sources":["../../src/stylelint/rules/license-header.ts","../../src/stylelint/package-utils.ts","../../src/stylelint/index.ts"],"sourcesContent":["\nimport { readFile } from 'node:fs/promises'\nimport stylelint from 'stylelint'\n\nconst { createPlugin, utils: { ruleMessages, validateOptions, report } } = stylelint\n\n// types ======================================================================\n\ntype RuleMeta = stylelint.RuleMeta\ntype RuleFunction = stylelint.RuleBase<string, unknown>\n\n// constants ==================================================================\n\nconst ruleName = 'license-header/header'\n\nconst messages = ruleMessages(ruleName, {\n rejectedMissing: 'Missing license header',\n rejectedInvalid: 'Invalid license header',\n})\n\nconst meta: RuleMeta = {\n url: 'https://gitlab.com/openxchange/appsuite/documents/commons/plugins/-/blob/main/packages/linter-presets/docs/stylelint/README.md',\n fixable: true,\n}\n\n/**\n * Cache for the contents of license header files, keyed by file path.\n */\nconst promiseCache = new Map<string, Promise<string>>()\n\n// functions ==================================================================\n\n/**\n * Reads the license header file once per file path.\n *\n * @param path\n * The path to the license header file.\n *\n * @returns\n * A promise that will resolve with the contents of the license header file.\n */\nconst readLicenseHeaderOnce = async (path: string): Promise<string> => {\n let promise = promiseCache.get(path)\n if (!promise) {\n promise = readFile(path, 'utf-8')\n promiseCache.set(path, promise)\n }\n return await promise\n}\n\n/**\n * Implementation of the linter rule.\n *\n * @param primary\n * The path to the license header file.\n *\n * @returns\n * The callback function for the linter.\n */\nconst ruleFunc: RuleFunction = (primary) => async (root, result) => {\n\n // validate rule options\n if (!validateOptions(result, ruleName, {\n actual: primary,\n possible: path => (typeof path === 'string') && (path.length > 0),\n })) return\n\n // find the first comment in the linted file\n type Comment = Parameters<Parameters<typeof root.walkComments>[0]>[0]\n let comment: Comment | undefined\n root.walkComments(node => {\n if (node.parent === root) comment = node // must be a top-level comment\n return false // always stop iteration after first comment\n })\n\n // read the license header file\n const license = await readLicenseHeaderOnce(primary)\n\n // exit successfully if comment found and matches the license header file\n if (comment) {\n // strip block comment markers for comparison\n const stripped = license.trim().replace(/^\\/\\*|\\*\\/$/g, '').trim()\n if (comment.text === stripped) return\n }\n\n // report missing or mismatching comment\n report({\n ruleName,\n result,\n message: comment ? messages.rejectedInvalid : messages.rejectedMissing,\n node: comment ?? root,\n fix: () => { root.prepend(license) },\n })\n}\n\n// exports ====================================================================\n\nexport default createPlugin(ruleName, Object.assign(ruleFunc, { meta, ruleName, messages }))\n","import { fileURLToPath } from 'node:url'\n\n// functions ==================================================================\n\n/**\n * Resolves the name of an extension or plugin package to the absolute path of\n * its entry file, as seen from this package.\n *\n * StyleLint resolves package names in the options `extends` and `plugins`\n * relative to the configuration file of the consumer project. With the strict\n * `node_modules` layout of pnpm, the packages installed as dependencies of\n * this package are not visible from there. An absolute path circumvents this\n * resolution. StyleLint resolves nested `extends` entries of the referenced\n * package relative to that package's own location, so the transitive packages\n * do not need any special handling.\n *\n * @param name\n * The name of the package to be resolved, optionally with a subpath (e.g.\n * 'stylelint-config-standard-vue/scss').\n *\n * @returns\n * The absolute path of the entry file of the package.\n */\nexport function resolvePackage(name: string): string {\n return fileURLToPath(import.meta.resolve(name))\n}\n","\nimport type { Config } from 'stylelint'\n\nimport licensePlugin from '@/stylelint/rules/license-header.ts'\nimport { resolvePackage } from '@/stylelint/package-utils.ts'\nimport { PathResolver } from '@/utils/resolver.ts'\n\n// types ======================================================================\n\n/**\n * Configuration for multiple rules.\n */\nexport type RuleRecord = NonNullable<Config['rules']>\n\n// ----------------------------------------------------------------------------\n\n/**\n * Configuration options for StyleLint code style rules.\n */\nexport interface StylisticOptions {\n\n /**\n * Default indentation size (number of space characters).\n *\n * @default 2\n */\n indent?: number\n\n /**\n * The quote character for string literals, or 'off' to disable the quote\n * check.\n *\n * @default 'single'\n */\n quotes?: 'single' | 'double' | 'off'\n}\n\n// ----------------------------------------------------------------------------\n\n/**\n * Configuration options for linting vue files.\n */\nexport interface VueOptions {\n\n /**\n * The language variant of `stylelint-config-standard-vue` to be used.\n *\n * @default 'css'\n */\n lang?: 'css' | 'scss'\n\n /**\n * Additional linter rules for Vue source files to be added to the global\n * configuration.\n */\n rules?: RuleRecord\n}\n\n// ----------------------------------------------------------------------------\n\n/**\n * Configuration options for linting the entire project with StyleLint.\n */\nexport interface ProjectOptions {\n\n /**\n * The URL of the StyleLint configuration file in the project root. Should\n * usually be set to `import.meta.url`.\n */\n root: string\n\n /**\n * Glob patterns for all files to be ignored by StyleLint (the patterns must\n * match files, plain directory names are not supported).\n */\n ignores?: string[]\n\n /**\n * Path to the template file containing the license header to be used in all\n * linted stylesheet files. May be a path relative to the project root.\n */\n license?: string\n\n /**\n * Whether the project uses TailwindCSS. If set, the configuration package\n * `stylelint-config-tailwindcss` will be added.\n */\n tailwind?: boolean\n\n /**\n * Configuration options for code style.\n */\n stylistic?: StylisticOptions\n\n /**\n * Options for linting styles in Vue files.\n */\n vue?: VueOptions\n\n /**\n * Additional linter rules to be added to the global configuration. Rule\n * names starting with `scss/` or `less/` will automatically be assigned to\n * the respective language override configuration.\n */\n rules?: RuleRecord\n}\n\n// functions ==================================================================\n\n/**\n * Generates a StyleLint configuration object targeting the source files in the\n * entire project.\n *\n * @param options\n * Project configuration options.\n *\n * @returns\n * The configuration object to be exported from the project's configuration\n * file (e.g. `stylelint.config.ts`).\n */\nexport function defineConfig(options: ProjectOptions): Config {\n\n const ignoreFiles: string[] = [\n 'node_modules/**/*',\n 'dist/**/*',\n 'output/**/*',\n 'coverage/**/*', // Vitest\n '.nuxt/**/*', // NuxtJS\n '.output/**/*', // NuxtJS\n ...(options.ignores ?? []),\n ]\n\n // resolve stylistic configuration options\n const stylistic: StylisticOptions = {\n indent: 2,\n quotes: 'single',\n ...options.stylistic,\n }\n\n // the resolver for relative file paths\n const resolver = new PathResolver(options.root)\n\n // custom extensions, grouped by language type (resolved to absolute paths,\n // see function 'resolvePackage' for details)\n const extensions = {\n base: [\n resolvePackage('stylelint-config-standard'),\n resolvePackage('@stylistic/stylelint-config'),\n ],\n scss: [\n resolvePackage('stylelint-config-standard-scss'),\n ],\n less: [\n resolvePackage('stylelint-config-standard-less'),\n ],\n vue: [\n resolvePackage((options.vue?.lang === 'scss') ? 'stylelint-config-standard-vue/scss' : 'stylelint-config-standard-vue'),\n ],\n } satisfies Record<string, Config['extends']>\n\n // add TailwindCSS extension if specified\n if (options.tailwind) {\n extensions.base.push(resolvePackage('stylelint-config-tailwindcss'))\n }\n\n // custom rules, grouped by language type\n const rules: Record<string, RuleRecord> = {\n base: {\n 'at-rule-empty-line-before': null,\n 'color-function-notation': ['modern', { ignore: ['with-var-inside'] }],\n 'color-hex-length': null,\n 'comment-empty-line-before': null,\n 'custom-property-empty-line-before': null,\n 'declaration-block-no-redundant-longhand-properties': [true, { ignoreShorthands: ['inset'] }], // Safari does not support 'inset'\n 'declaration-block-single-line-max-declarations': null,\n 'declaration-empty-line-before': null,\n 'function-url-no-scheme-relative': true,\n 'function-url-scheme-allowed-list': ['data'],\n 'media-feature-range-notation': 'prefix', // Safari 16.3 does not work with this notation\n 'no-descending-specificity': null,\n 'no-unknown-animations': true,\n 'rule-empty-line-before': null,\n 'shorthand-property-no-redundant-values': [true, { ignore: ['four-into-three-edge-values'] }],\n // override rules of @stylistic plugin\n '@stylistic/declaration-colon-newline-after': null,\n '@stylistic/indentation': [stylistic.indent, { ignore: ['inside-parens'] }],\n '@stylistic/max-line-length': null,\n '@stylistic/no-empty-first-line': null,\n '@stylistic/selector-list-comma-newline-after': null,\n '@stylistic/string-quotes': (stylistic.quotes === 'off') ? null : [stylistic.quotes, { avoidEscape: true }],\n },\n scss: {\n 'scss/dollar-variable-empty-line-before': null,\n 'scss/double-slash-comment-empty-line-before': null,\n },\n less: {},\n vue: {\n ...options.vue?.rules,\n },\n }\n\n // distribute custom rules by language type\n if (options.rules) {\n for (const [name, rule] of Object.entries(options.rules)) {\n const key = name.split('/')[0];\n (rules[key] ?? rules.base)[name] = rule as unknown\n }\n }\n\n // custom overrides\n const overrides: Config['overrides'] = [{\n files: ['**/*.scss'],\n extends: extensions.scss,\n rules: rules.scss,\n }, {\n files: ['**/*.less'],\n extends: extensions.less,\n rules: rules.less,\n }, {\n files: ['**/*.vue'],\n extends: extensions.vue,\n rules: rules.vue,\n }]\n\n // license header plugin\n if (options.license) {\n overrides.push({\n files: ['**/*.{css,scss,less}'], // not for Vue files\n plugins: licensePlugin,\n rules: {\n 'license-header/header': resolver.path(options.license),\n },\n })\n }\n\n return {\n\n // ignore certain files and folders\n ignoreFiles,\n\n // check inline directives\n reportDescriptionlessDisables: null,\n reportInvalidScopeDisables: true,\n reportNeedlessDisables: true,\n reportUnscopedDisables: true,\n\n // add all extensions, rules, and overrides configured above\n extends: extensions.base,\n rules: rules.base,\n overrides,\n }\n}\n"],"mappings":";;;;;AAIA,MAAM,EAAE,cAAc,OAAO,EAAE,cAAc,iBAAiB,aAAa;AAS3E,MAAM,WAAW;AAEjB,MAAM,WAAW,aAAa,UAAU;CACtC,iBAAiB;CACjB,iBAAiB;AACnB,CAAC;AAED,MAAM,OAAiB;CACrB,KAAK;CACL,SAAS;AACX;;;;AAKA,MAAM,+BAAe,IAAI,IAA6B;;;;;;;;;;AAatD,MAAM,wBAAwB,OAAO,SAAkC;CACrE,IAAI,UAAU,aAAa,IAAI,IAAI;CACnC,IAAI,CAAC,SAAS;EACZ,UAAU,SAAS,MAAM,OAAO;EAChC,aAAa,IAAI,MAAM,OAAO;CAChC;CACA,OAAO,MAAM;AACf;;;;;;;;;;AAWA,MAAM,YAA0B,YAAY,OAAO,MAAM,WAAW;CAGlE,IAAI,CAAC,gBAAgB,QAAQ,UAAU;EACrC,QAAQ;EACR,WAAU,SAAS,OAAO,SAAS,YAAc,KAAK,SAAS;CACjE,CAAC,GAAG;CAIJ,IAAI;CACJ,KAAK,cAAa,SAAQ;EACxB,IAAI,KAAK,WAAW,MAAM,UAAU;EACpC,OAAO;CACT,CAAC;CAGD,MAAM,UAAU,MAAM,sBAAsB,OAAO;CAGnD,IAAI,SAAS;EAEX,MAAM,WAAW,QAAQ,KAAK,CAAC,CAAC,QAAQ,gBAAgB,EAAE,CAAC,CAAC,KAAK;EACjE,IAAI,QAAQ,SAAS,UAAU;CACjC;CAGA,OAAO;EACL;EACA;EACA,SAAS,UAAU,SAAS,kBAAkB,SAAS;EACvD,MAAM,WAAW;EACjB,WAAW;GAAE,KAAK,QAAQ,OAAO;EAAE;CACrC,CAAC;AACH;AAIA,IAAA,yBAAe,aAAa,UAAU,OAAO,OAAO,UAAU;CAAE;CAAM;CAAU;AAAS,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;AC1E3F,SAAgB,eAAe,MAAsB;C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A,MAAM;GACJ,0CAA0C;GAC1C,+CAA+C;EACjD;EACA,MAAM,CAAC;EACP,KAAK,EACH,GAAG,QAAQ,KAAK,MAClB;CACF;CAGA,IAAI,QAAQ,OACV,KAAK,MAAM,CAAC,MAAM,SAAS,OAAO,QAAQ,QAAQ,KAAK,GAAG;EACxD,MAAM,MAAM,KAAK,MAAM,GAAG,CAAC,CAAC;EAC5B,CAAC,MAAM,QAAQ,MAAM,KAAA,CAAM,QAAQ;CACrC;CAIF,MAAM,YAAiC;EAAC;GACtC,OAAO,CAAC,WAAW;GACnB,SAAS,WAAW;GACpB,OAAO,MAAM;EACf;EAAG;GACD,OAAO,CAAC,WAAW;GACnB,SAAS,WAAW;GACpB,OAAO,MAAM;EACf;EAAG;GACD,OAAO,CAAC,UAAU;GAClB,SAAS,WAAW;GACpB,OAAO,MAAM;EACf;CAAC;CAGD,IAAI,QAAQ,SACV,UAAU,KAAK;EACb,OAAO,CAAC,sBAAsB;EAC9B,SAASA;EACT,OAAO,EACL,yBAAyB,SAAS,KAAK,QAAQ,OAAO,EACxD;CACF,CAAC;CAGH,OAAO;EAGL;EAGA,+BAA+B;EAC/B,4BAA4B;EAC5B,wBAAwB;EACxB,wBAAwB;EAGxB,SAAS,WAAW;EACpB,OAAO,MAAM;EACb;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["stylisticConfigRules","rules","licensePlugin"],"sources":["../../src/stylelint/rules/license-header.ts","../../src/stylelint/package-utils.ts","../../src/stylelint/index.ts"],"sourcesContent":["\nimport { readFile } from 'node:fs/promises'\nimport stylelint from 'stylelint'\n\nconst { createPlugin, utils: { ruleMessages, validateOptions, report } } = stylelint\n\n// types ======================================================================\n\ntype RuleMeta = stylelint.RuleMeta\ntype RuleFunction = stylelint.RuleBase<string, unknown>\n\n// constants ==================================================================\n\nconst ruleName = 'license-header/header'\n\nconst messages = ruleMessages(ruleName, {\n rejectedMissing: 'Missing license header',\n rejectedInvalid: 'Invalid license header',\n})\n\nconst meta: RuleMeta = {\n url: 'https://gitlab.com/openxchange/appsuite/documents/commons/plugins/-/blob/main/packages/linter-presets/docs/stylelint/README.md',\n fixable: true,\n}\n\n/**\n * Cache for the contents of license header files, keyed by file path.\n */\nconst promiseCache = new Map<string, Promise<string>>()\n\n// functions ==================================================================\n\n/**\n * Reads the license header file once per file path.\n *\n * @param path\n * The path to the license header file.\n *\n * @returns\n * A promise that will resolve with the contents of the license header file.\n */\nconst readLicenseHeaderOnce = async (path: string): Promise<string> => {\n let promise = promiseCache.get(path)\n if (!promise) {\n promise = readFile(path, 'utf-8')\n promiseCache.set(path, promise)\n }\n return await promise\n}\n\n/**\n * Implementation of the linter rule.\n *\n * @param primary\n * The path to the license header file.\n *\n * @returns\n * The callback function for the linter.\n */\nconst ruleFunc: RuleFunction = (primary) => async (root, result) => {\n\n // validate rule options\n if (!validateOptions(result, ruleName, {\n actual: primary,\n possible: path => (typeof path === 'string') && (path.length > 0),\n })) return\n\n // find the first comment in the linted file\n type Comment = Parameters<Parameters<typeof root.walkComments>[0]>[0]\n let comment: Comment | undefined\n root.walkComments(node => {\n if (node.parent === root) comment = node // must be a top-level comment\n return false // always stop iteration after first comment\n })\n\n // read the license header file\n const license = await readLicenseHeaderOnce(primary)\n\n // exit successfully if comment found and matches the license header file\n if (comment) {\n // strip block comment markers for comparison\n const stripped = license.trim().replace(/^\\/\\*|\\*\\/$/g, '').trim()\n if (comment.text === stripped) return\n }\n\n // report missing or mismatching comment\n report({\n ruleName,\n result,\n message: comment ? messages.rejectedInvalid : messages.rejectedMissing,\n node: comment ?? root,\n fix: () => { root.prepend(license) },\n })\n}\n\n// exports ====================================================================\n\nexport default createPlugin(ruleName, Object.assign(ruleFunc, { meta, ruleName, messages }))\n","import { fileURLToPath } from 'node:url'\n\n// functions ==================================================================\n\n/**\n * Resolves the name of an extension or plugin package to the absolute path of\n * its entry file, as seen from this package.\n *\n * StyleLint resolves package names in the options `extends` and `plugins`\n * relative to the configuration file of the consumer project. With the strict\n * `node_modules` layout of pnpm, the packages installed as dependencies of\n * this package are not visible from there. An absolute path circumvents this\n * resolution. StyleLint resolves nested `extends` entries of the referenced\n * package relative to that package's own location, so the transitive packages\n * do not need any special handling.\n *\n * @param name\n * The name of the package to be resolved, optionally with a subpath (e.g.\n * 'stylelint-config-standard-vue/scss').\n *\n * @returns\n * The absolute path of the entry file of the package.\n */\nexport function resolvePackage(name: string): string {\n return fileURLToPath(import.meta.resolve(name))\n}\n","\nimport type { Config } from 'stylelint'\nimport standardLessConfig from 'stylelint-config-standard-less'\nimport standardScssConfig from 'stylelint-config-standard-scss'\nimport { rules as stylisticConfigRules } from '@stylistic/stylelint-config'\n\nimport licensePlugin from '@/stylelint/rules/license-header.ts'\nimport { resolvePackage } from '@/stylelint/package-utils.ts'\nimport { PathResolver } from '@/utils/resolver.ts'\n\n// types ======================================================================\n\n/**\n * Configuration for multiple rules.\n */\nexport type RuleRecord = NonNullable<Config['rules']>\n\n// ----------------------------------------------------------------------------\n\n/**\n * Configuration options for StyleLint code style rules.\n */\nexport interface StylisticOptions {\n\n /**\n * Default indentation size (number of space characters).\n *\n * @default 2\n */\n indent?: number\n\n /**\n * The quote character for string literals, or 'off' to disable the quote\n * check.\n *\n * @default 'single'\n */\n quotes?: 'single' | 'double' | 'off'\n}\n\n// ----------------------------------------------------------------------------\n\n/**\n * Configuration options for linting vue files.\n */\nexport interface VueOptions {\n\n /**\n * The language variant of `stylelint-config-standard-vue` to be used.\n *\n * @default 'css'\n */\n lang?: 'css' | 'scss'\n\n /**\n * Additional linter rules for Vue source files to be added to the global\n * configuration.\n */\n rules?: RuleRecord\n}\n\n// ----------------------------------------------------------------------------\n\n/**\n * Configuration options for linting the entire project with StyleLint.\n */\nexport interface ProjectOptions {\n\n /**\n * The URL of the StyleLint configuration file in the project root. Should\n * usually be set to `import.meta.url`.\n */\n root: string\n\n /**\n * Glob patterns for all files to be ignored by StyleLint (the patterns must\n * match files, plain directory names are not supported).\n */\n ignores?: string[]\n\n /**\n * Path to the template file containing the license header to be used in all\n * linted stylesheet files. May be a path relative to the project root.\n */\n license?: string\n\n /**\n * Whether the project uses TailwindCSS. If set, the configuration package\n * `stylelint-config-tailwindcss` will be added.\n */\n tailwind?: boolean\n\n /**\n * Configuration options for code style.\n */\n stylistic?: StylisticOptions\n\n /**\n * Options for linting styles in Vue files.\n */\n vue?: VueOptions\n\n /**\n * Additional linter rules to be added to the global configuration. Rule\n * names starting with `scss/` or `less/` (also `@stylistic/scss/` or\n * `@stylistic/less/`) will automatically be assigned to the respective\n * language override configuration. Rules of the `@stylistic` plugin without\n * syntax namespace (e.g. `@stylistic/indentation`) will be applied to SCSS\n * and Less files too.\n */\n rules?: RuleRecord\n}\n\n// constants ==================================================================\n\n// matches names of @stylistic rules without syntax namespace, and captures the short rule name\nconst STYLISTIC_RULE_RE = /^@stylistic\\/([^/]+)$/\n\n// rules of `stylelint-config-recommended` that report valid SCSS syntax\nconst SCSS_DISABLED_RULES: RuleRecord = {\n 'value-no-invalid': null, // e.g. keyword arguments in `rgba($color: #000, $alpha: 50%)`\n}\n\n// rules of `stylelint-config-recommended` that report valid Less syntax\nconst LESS_DISABLED_RULES: RuleRecord = {\n 'selector-no-invalid': null, // mixin definitions with parameters\n 'selector-no-unmatchable': null, // parent selector `&` resolving to pseudo-elements\n 'value-no-invalid': null, // variables, operations, and functions of Less\n}\n\n// helpers ====================================================================\n\n/**\n * Adds a namespace prefix to the names of all passed rules.\n *\n * @param rules\n * The rule settings to be prefixed.\n *\n * @param prefix\n * The namespace prefix for all rule names, without trailing slash.\n *\n * @returns\n * The rule settings with prefixed rule names.\n */\nfunction prefixRules(rules: RuleRecord, prefix: string): RuleRecord {\n return Object.fromEntries(Object.entries(rules).map(([name, rule]) => [`${prefix}/${name}`, rule]))\n}\n\n// functions ==================================================================\n\n/**\n * Generates a StyleLint configuration object targeting the source files in the\n * entire project.\n *\n * @param options\n * Project configuration options.\n *\n * @returns\n * The configuration object to be exported from the project's configuration\n * file (e.g. `stylelint.config.ts`).\n */\nexport function defineConfig(options: ProjectOptions): Config {\n\n const ignoreFiles: string[] = [\n 'node_modules/**/*',\n 'dist/**/*',\n 'output/**/*',\n 'coverage/**/*', // Vitest\n '.nuxt/**/*', // NuxtJS\n '.output/**/*', // NuxtJS\n ...(options.ignores ?? []),\n ]\n\n // resolve stylistic configuration options\n const stylistic: StylisticOptions = {\n indent: 2,\n quotes: 'single',\n ...options.stylistic,\n }\n\n // the resolver for relative file paths\n const resolver = new PathResolver(options.root)\n\n // The packages 'stylelint-config-standard-scss' and '-less' extend version 40\n // of 'stylelint-config-standard' which enables a rule removed in StyleLint 18\n // (reported as unknown rule in every file). Until they support StyleLint 18,\n // extend their base packages and add their own rules only, the package\n // 'stylelint-config-standard' is already extended for all languages.\n // TODO: extend the packages directly when they support StyleLint 18\n const standardScss = [\n resolvePackage('stylelint-config-recommended-scss'),\n { rules: standardScssConfig.rules },\n { rules: SCSS_DISABLED_RULES },\n ]\n\n // custom extensions, grouped by language type (packages resolved to absolute\n // paths, see function 'resolvePackage' for details)\n const extensions = {\n base: [\n resolvePackage('stylelint-config-standard'),\n resolvePackage('@stylistic/stylelint-config'),\n ],\n scss: standardScss,\n less: [\n resolvePackage('stylelint-config-recommended-less'),\n { rules: standardLessConfig.rules },\n { rules: LESS_DISABLED_RULES },\n ],\n vue: (options.vue?.lang === 'scss') ? [\n // replaces 'stylelint-config-standard-vue/scss' which extends 'stylelint-config-standard-scss'\n // (package 'stylelint-config-recommended-vue/scss' must follow to restore the syntax 'postcss-html')\n resolvePackage('stylelint-config-standard-vue'),\n ...standardScss,\n resolvePackage('stylelint-config-recommended-vue/scss'),\n // '@stylistic/stylelint-config' sets the SCSS namespace for `*.scss` files only\n { rules: prefixRules(stylisticConfigRules, '@stylistic/scss') },\n ] : [\n resolvePackage('stylelint-config-standard-vue'),\n ],\n } satisfies Record<string, Config['extends']>\n\n // add TailwindCSS extension if specified\n if (options.tailwind) {\n extensions.base.push(resolvePackage('stylelint-config-tailwindcss'))\n }\n\n // overrides for rules of the @stylistic plugin, by short rule name\n const stylisticRules: RuleRecord = {\n 'declaration-block-single-line-max-declarations': null,\n 'declaration-colon-newline-after': null,\n indentation: [stylistic.indent, { ignore: ['inside-parens'] }],\n 'max-line-length': null,\n 'no-empty-first-line': null,\n 'selector-list-comma-newline-after': null,\n 'string-quotes': (stylistic.quotes === 'off') ? null : [stylistic.quotes, { avoidEscape: true }],\n }\n\n // custom rules of the @stylistic plugin without syntax namespace apply to all languages\n const customRules = Object.entries(options.rules ?? {})\n for (const [name, rule] of customRules) {\n const match = STYLISTIC_RULE_RE.exec(name)\n if (match) { stylisticRules[match[1]] = rule as unknown }\n }\n\n // custom rules, grouped by language type (the @stylistic plugin checks SCSS\n // and Less files with copies of its rules in syntax namespaces, e.g.\n // '@stylistic/scss/indentation', the overrides must be set for all of them)\n const rules: Record<string, RuleRecord> = {\n base: {\n 'at-rule-empty-line-before': null,\n 'color-function-notation': ['modern', { ignore: ['with-var-inside'] }],\n 'color-hex-length': null,\n 'comment-empty-line-before': null,\n 'custom-property-empty-line-before': null,\n 'declaration-block-no-redundant-longhand-properties': [true, { ignoreShorthands: ['inset'] }], // Safari does not support 'inset'\n 'declaration-empty-line-before': null,\n 'function-url-no-scheme-relative': true,\n 'function-url-scheme-allowed-list': ['data'],\n 'media-feature-range-notation': 'prefix', // Safari 16.3 does not work with this notation\n 'no-descending-specificity': null,\n 'no-unknown-animations': true,\n 'rule-empty-line-before': null,\n 'shorthand-property-no-redundant-values': [true, { ignore: ['four-into-three-edge-values'] }],\n ...prefixRules(stylisticRules, '@stylistic'),\n },\n scss: {\n 'scss/dollar-variable-empty-line-before': null,\n 'scss/double-slash-comment-empty-line-before': null,\n ...prefixRules(stylisticRules, '@stylistic/scss'),\n },\n less: {\n ...prefixRules(stylisticRules, '@stylistic/less'),\n },\n vue: {\n ...((options.vue?.lang === 'scss') ? prefixRules(stylisticRules, '@stylistic/scss') : undefined),\n ...options.vue?.rules,\n },\n }\n\n // distribute the other custom rules by language type (namespace of the rule\n // name, e.g. 'scss/' or '@stylistic/scss/')\n for (const [name, rule] of customRules) {\n if (!STYLISTIC_RULE_RE.test(name)) {\n const key = name.replace(/^@stylistic\\//, '').split('/')[0];\n (rules[key] ?? rules.base)[name] = rule as unknown\n }\n }\n\n // custom overrides\n const overrides: Config['overrides'] = [{\n files: ['**/*.scss'],\n extends: extensions.scss,\n rules: rules.scss,\n }, {\n files: ['**/*.less'],\n extends: extensions.less,\n rules: rules.less,\n }, {\n files: ['**/*.vue'],\n extends: extensions.vue,\n rules: rules.vue,\n }]\n\n // license header plugin\n if (options.license) {\n overrides.push({\n files: ['**/*.{css,scss,less}'], // not for Vue files\n plugins: licensePlugin,\n rules: {\n 'license-header/header': resolver.path(options.license),\n },\n })\n }\n\n return {\n\n // ignore certain files and folders\n ignoreFiles,\n\n // check inline directives\n reportDescriptionlessDisables: null,\n reportInvalidScopeDisables: true,\n reportNeedlessDisables: true,\n reportUnscopedDisables: true,\n\n // add all extensions, rules, and overrides configured above\n extends: extensions.base,\n rules: rules.base,\n overrides,\n }\n}\n"],"mappings":";;;;;;;;AAIA,MAAM,EAAE,cAAc,OAAO,EAAE,cAAc,iBAAiB,aAAa;AAS3E,MAAM,WAAW;AAEjB,MAAM,WAAW,aAAa,UAAU;CACtC,iBAAiB;CACjB,iBAAiB;AACnB,CAAC;AAED,MAAM,OAAiB;CACrB,KAAK;CACL,SAAS;AACX;;;;AAKA,MAAM,+BAAe,IAAI,IAA6B;;;;;;;;;;AAatD,MAAM,wBAAwB,OAAO,SAAkC;CACrE,IAAI,UAAU,aAAa,IAAI,IAAI;CACnC,IAAI,CAAC,SAAS;EACZ,UAAU,SAAS,MAAM,OAAO;EAChC,aAAa,IAAI,MAAM,OAAO;CAChC;CACA,OAAO,MAAM;AACf;;;;;;;;;;AAWA,MAAM,YAA0B,YAAY,OAAO,MAAM,WAAW;CAGlE,IAAI,CAAC,gBAAgB,QAAQ,UAAU;EACrC,QAAQ;EAC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config
|
|
|
39
39
|
| `vue` | `VueOptions` | | Configuration options for linting `<style>` elements in Vue single component files. |
|
|
40
40
|
| `vue.lang` | `'css'\|'scss'` | `'css'` | The style language used in the Vue files. |
|
|
41
41
|
| `vue.rules` | `RuleRecord` | `{}` | Additional linter rules for Vue files. |
|
|
42
|
-
| `rules` | `RuleRecord` | `{}` | Additional linter rules to be added to the global configuration. Rule names starting with `scss/` or `less/` will automatically be assigned to the respective language override configuration. |
|
|
42
|
+
| `rules` | `RuleRecord` | `{}` | Additional linter rules to be added to the global configuration. Rule names starting with `scss/` or `less/` (also `@stylistic/scss/` or `@stylistic/less/`) will automatically be assigned to the respective language override configuration. Rules of the `@stylistic` plugin without syntax namespace (e.g. `@stylistic/indentation`) will be applied to SCSS and Less files too. |
|
|
43
43
|
|
|
44
44
|
#### Built-in Ignore Globs
|
|
45
45
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-xchange/linter-presets",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.32.0",
|
|
4
4
|
"description": "Configuration presets for ESLint and StyleLint",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"engines": {
|
|
12
|
-
"node": ">=
|
|
12
|
+
"node": "^24.15.0 || >=26.0.0"
|
|
13
13
|
},
|
|
14
14
|
"type": "module",
|
|
15
15
|
"exports": {
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"CHANGELOG.*"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@babel/core": "^8.0
|
|
29
|
+
"@babel/core": "^8.1.0",
|
|
30
30
|
"@babel/eslint-parser": "^8.0.7",
|
|
31
31
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.8.1",
|
|
32
|
-
"@eslint-react/eslint-plugin": "^5.28.
|
|
33
|
-
"@eslint-react/kit": "^5.28.
|
|
32
|
+
"@eslint-react/eslint-plugin": "^5.28.8",
|
|
33
|
+
"@eslint-react/kit": "^5.28.8",
|
|
34
34
|
"@eslint/compat": "^2.1.1",
|
|
35
35
|
"@eslint/config-helpers": "^0.7.0",
|
|
36
36
|
"@eslint/core": "^1.2.1",
|
|
@@ -38,14 +38,13 @@
|
|
|
38
38
|
"@eslint/markdown": "^8.0.3",
|
|
39
39
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
40
40
|
"@stylistic/eslint-plugin-migrate": "^4.4.1",
|
|
41
|
-
"@stylistic/stylelint-config": "^
|
|
42
|
-
"@stylistic/stylelint-plugin": "^
|
|
41
|
+
"@stylistic/stylelint-config": "^6.0.0",
|
|
42
|
+
"@stylistic/stylelint-plugin": "^6.0.0",
|
|
43
43
|
"@types/json-schema": "^7.0.15",
|
|
44
44
|
"@types/picomatch": "^4.0.3",
|
|
45
45
|
"@vitest/eslint-plugin": "^1.6.28",
|
|
46
46
|
"@vue/eslint-config-typescript": "^14.9.0",
|
|
47
47
|
"confusing-browser-globals": "^1.0.11",
|
|
48
|
-
"empathic": "^2.1.0",
|
|
49
48
|
"eslint-plugin-chai-expect": "^4.1.1",
|
|
50
49
|
"eslint-plugin-codeceptjs": "^1.3.0",
|
|
51
50
|
"eslint-plugin-depend": "^1.5.0",
|
|
@@ -53,7 +52,7 @@
|
|
|
53
52
|
"eslint-plugin-jest": "^29.17.0",
|
|
54
53
|
"eslint-plugin-jest-dom": "^5.10.1",
|
|
55
54
|
"eslint-plugin-jest-extended": "^3.0.1",
|
|
56
|
-
"eslint-plugin-jsdoc": "^65.4.
|
|
55
|
+
"eslint-plugin-jsdoc": "^65.4.2",
|
|
57
56
|
"eslint-plugin-jsonc": "^3.4.2",
|
|
58
57
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
59
58
|
"eslint-plugin-license-header": "^0.9.0",
|
|
@@ -62,42 +61,42 @@
|
|
|
62
61
|
"eslint-plugin-promise": "^7.3.0",
|
|
63
62
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
64
63
|
"eslint-plugin-react-refresh": "^0.5.7",
|
|
65
|
-
"eslint-plugin-regexp": "^3.3.
|
|
64
|
+
"eslint-plugin-regexp": "^3.3.3",
|
|
66
65
|
"eslint-plugin-testing-library": "^7.16.2",
|
|
67
|
-
"eslint-plugin-vue": "^10.
|
|
66
|
+
"eslint-plugin-vue": "^10.12.0",
|
|
68
67
|
"eslint-plugin-yml": "^3.9.0",
|
|
69
|
-
"globals": "^17.
|
|
68
|
+
"globals": "^17.14.0",
|
|
70
69
|
"picomatch": "^4.0.7",
|
|
71
70
|
"postcss-html": "^2.0.0",
|
|
72
71
|
"stylelint-config-html": "^2.0.0",
|
|
73
|
-
"stylelint-config-recommended": "^
|
|
72
|
+
"stylelint-config-recommended": "^19.0.0",
|
|
74
73
|
"stylelint-config-recommended-less": "^4.2.1",
|
|
75
74
|
"stylelint-config-recommended-scss": "^17.0.1",
|
|
76
75
|
"stylelint-config-recommended-vue": "^2.0.0",
|
|
77
|
-
"stylelint-config-standard": "^
|
|
76
|
+
"stylelint-config-standard": "^41.0.0",
|
|
78
77
|
"stylelint-config-standard-less": "^4.1.0",
|
|
79
78
|
"stylelint-config-standard-scss": "^17.0.0",
|
|
80
79
|
"stylelint-config-standard-vue": "^2.0.0",
|
|
81
80
|
"stylelint-config-tailwindcss": "^1.0.1",
|
|
82
81
|
"stylelint-less": "^4.2.2",
|
|
83
|
-
"stylelint-scss": "^7.
|
|
84
|
-
"typescript-eslint": "^8.72.
|
|
82
|
+
"stylelint-scss": "^7.4.0",
|
|
83
|
+
"typescript-eslint": "^8.72.1"
|
|
85
84
|
},
|
|
86
85
|
"devDependencies": {
|
|
87
86
|
"@jest/globals": "^30.5.2",
|
|
88
87
|
"@open-xchange/tsconfig": "^0.2.4",
|
|
89
88
|
"@types/confusing-browser-globals": "^1.0.3",
|
|
90
89
|
"@types/react": "^19.3.0",
|
|
91
|
-
"@typescript-eslint/utils": "^8.72.
|
|
92
|
-
"eslint": "^10.
|
|
90
|
+
"@typescript-eslint/utils": "^8.72.1",
|
|
91
|
+
"eslint": "^10.14.0",
|
|
93
92
|
"jest": "^30.5.2",
|
|
94
|
-
"stylelint": "^
|
|
95
|
-
"vitest": "^5.0
|
|
93
|
+
"stylelint": "^18.0.0",
|
|
94
|
+
"vitest": "^5.1.0"
|
|
96
95
|
},
|
|
97
96
|
"peerDependencies": {
|
|
98
97
|
"eslint": "^9.35.0 || ^10.0.0",
|
|
99
|
-
"postcss": "^8.
|
|
100
|
-
"stylelint": "^
|
|
98
|
+
"postcss": "^8.5.0",
|
|
99
|
+
"stylelint": "^18.0.0",
|
|
101
100
|
"typescript": "^5.9.0 || ^6.0.0 || ^7.0.0"
|
|
102
101
|
},
|
|
103
102
|
"peerDependenciesMeta": {
|