@open-xchange/linter-presets 1.30.7 → 1.31.1

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.
@@ -12,6 +12,8 @@ var PathResolver = class {
12
12
  this.#root = dirname(fileURLToPath(url));
13
13
  }
14
14
  /**
15
+ * Returns the directory path of the URL passed to the constructor.
16
+ *
15
17
  * @returns
16
18
  * The directory path of the URL passed to the constructor.
17
19
  */
@@ -34,4 +36,4 @@ var PathResolver = class {
34
36
  //#endregion
35
37
  export { PathResolver as t };
36
38
 
37
- //# sourceMappingURL=resolver-Nkg5OKUN.mjs.map
39
+ //# sourceMappingURL=resolver-CKKbaGEf.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver-CKKbaGEf.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"}
@@ -15,7 +15,8 @@ export interface StylisticOptions {
15
15
  */
16
16
  indent?: number;
17
17
  /**
18
- * The type of the string delimiter character.
18
+ * The quote character for string literals, or 'off' to disable the quote
19
+ * check.
19
20
  *
20
21
  * @default 'single'
21
22
  */
@@ -26,7 +27,7 @@ export interface StylisticOptions {
26
27
  */
27
28
  export interface VueOptions {
28
29
  /**
29
- * The language parser plugin to be used.
30
+ * The language variant of `stylelint-config-standard-vue` to be used.
30
31
  *
31
32
  * @default 'css'
32
33
  */
@@ -42,8 +43,8 @@ export interface VueOptions {
42
43
  */
43
44
  export interface ProjectOptions {
44
45
  /**
45
- * The URL of the project root containing the StyleLint configuration file.
46
- * Should usually be set to `import.meta.url`.
46
+ * The URL of the StyleLint configuration file in the project root. Should
47
+ * usually be set to `import.meta.url`.
47
48
  */
48
49
  root: string;
49
50
  /**
@@ -53,12 +54,12 @@ export interface ProjectOptions {
53
54
  ignores?: string[];
54
55
  /**
55
56
  * Path to the template file containing the license header to be used in all
56
- * source files. May be a path relative to the project root.
57
+ * linted stylesheet files. May be a path relative to the project root.
57
58
  */
58
59
  license?: string;
59
60
  /**
60
- * Whether the project uses TailwindCSS. Causes to add the configuration
61
- * package `stylelint-config-tailwindcss`.
61
+ * Whether the project uses TailwindCSS. If set, the configuration package
62
+ * `stylelint-config-tailwindcss` will be added.
62
63
  */
63
64
  tailwind?: boolean;
64
65
  /**
@@ -81,10 +82,11 @@ export interface ProjectOptions {
81
82
  * entire project.
82
83
  *
83
84
  * @param options
84
- * Plugin configuration options.
85
+ * Project configuration options.
85
86
  *
86
87
  * @returns
87
- * The configuration object to be exported from `stylelint.config.js`.
88
+ * The configuration object to be exported from the project's configuration
89
+ * file (e.g. `stylelint.config.ts`).
88
90
  */
89
91
  export declare function defineConfig(options: ProjectOptions): Config;
90
92
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/stylelint/index.ts"],"mappings":";;;;;YAYY,aAAa,YAAY;;;;iBAOpB;;;;;;EAOf;;;;;;EAOA;;;;;iBAQe;;;;;;EAOf;;;;;EAMA,QAAQ;;;;;iBAQO;;;;;EAMf;;;;;EAMA;;;;;EAMA;;;;;EAMA;;;;EAKA,YAAY;;;;EAKZ,MAAM;;;;;;EAON,QAAQ;;;;;;;;;;;;wBAeM,aAAa,SAAS,iBAAiB"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/stylelint/index.ts"],"mappings":";;;;;YAYY,aAAa,YAAY;;;;iBAOpB;;;;;;EAOf;;;;;;;EAQA;;;;;iBAQe;;;;;;EAOf;;;;;EAMA,QAAQ;;;;;iBAQO;;;;;EAMf;;;;;EAMA;;;;;EAMA;;;;;EAMA;;;;EAKA,YAAY;;;;EAKZ,MAAM;;;;;;EAON,QAAQ;;;;;;;;;;;;;wBAgBM,aAAa,SAAS,iBAAiB"}
@@ -1,22 +1,7 @@
1
- import { t as PathResolver } from "../resolver-Nkg5OKUN.mjs";
1
+ import { t as PathResolver } from "../resolver-CKKbaGEf.mjs";
2
+ import { fileURLToPath } from "node:url";
2
3
  import { readFile } from "node:fs/promises";
3
4
  import stylelint from "stylelint";
4
- import lessPlugin from "stylelint-less";
5
- import scssPlugin from "stylelint-scss";
6
- import htmlConfig from "stylelint-config-html";
7
- import recommendedConfig from "stylelint-config-recommended";
8
- import recommendedLessConfig from "stylelint-config-recommended-less";
9
- import recommendedScssConfig from "stylelint-config-recommended-scss";
10
- import recommendedVueConfig from "stylelint-config-recommended-vue";
11
- import recommendedVueScssConfig from "stylelint-config-recommended-vue/scss";
12
- import standardConfig from "stylelint-config-standard";
13
- import standardLessConfig from "stylelint-config-standard-less";
14
- import standardScssConfig from "stylelint-config-standard-scss";
15
- import standardVueConfig from "stylelint-config-standard-vue";
16
- import standardVueScssConfig from "stylelint-config-standard-vue/scss";
17
- import stylisticPlugin from "@stylistic/stylelint-plugin";
18
- import stylisticConfig from "@stylistic/stylelint-config";
19
- import tailwindConfig from "stylelint-config-tailwindcss";
20
5
  //#region src/stylelint/rules/license-header.ts
21
6
  const { createPlugin, utils: { ruleMessages, validateOptions, report } } = stylelint;
22
7
  const ruleName = "license-header/header";
@@ -28,6 +13,9 @@ const meta = {
28
13
  url: "https://gitlab.com/openxchange/appsuite/documents/commons/plugins/-/blob/main/packages/linter-presets/docs/stylelint/README.md",
29
14
  fixable: true
30
15
  };
16
+ /**
17
+ * Cache for the contents of license header files, keyed by file path.
18
+ */
31
19
  const promiseCache = /* @__PURE__ */ new Map();
32
20
  /**
33
21
  * Reads the license header file once per file path.
@@ -87,65 +75,27 @@ var license_header_default = createPlugin(ruleName, Object.assign(ruleFunc, {
87
75
  }));
88
76
  //#endregion
89
77
  //#region src/stylelint/package-utils.ts
90
- const PLUGINS = {
91
- "@stylistic/stylelint-plugin": stylisticPlugin,
92
- "stylelint-less": lessPlugin,
93
- "stylelint-scss": scssPlugin
94
- };
95
- const CONFIGS = {
96
- "@stylistic/stylelint-config": stylisticConfig,
97
- "stylelint-config-html": htmlConfig,
98
- "stylelint-config-recommended": recommendedConfig,
99
- "stylelint-config-recommended-less": recommendedLessConfig,
100
- "stylelint-config-recommended-scss": recommendedScssConfig,
101
- "stylelint-config-recommended-vue": recommendedVueConfig,
102
- "stylelint-config-recommended-vue/scss": recommendedVueScssConfig,
103
- "stylelint-config-standard": standardConfig,
104
- "stylelint-config-standard-less": standardLessConfig,
105
- "stylelint-config-standard-scss": standardScssConfig,
106
- "stylelint-config-standard-vue": standardVueConfig,
107
- "stylelint-config-standard-vue/scss": standardVueScssConfig,
108
- "stylelint-config-tailwindcss": tailwindConfig
109
- };
110
- /**
111
- * Resolves string entries in the configuration options `plugins` and `extends`
112
- * to imported objects.
113
- *
114
- * @param config
115
- * The configuration to be resolved.
116
- */
117
- function resolveEntries(config) {
118
- config.plugins &&= [config.plugins].flat().map((entry) => {
119
- if (typeof entry !== "string") return entry;
120
- const resolved = PLUGINS[entry];
121
- if (!resolved) throw new Error(`unknown plugin package '${entry}'`);
122
- return resolved;
123
- });
124
- config.extends &&= [config.extends].flat().map((entry) => {
125
- if (typeof entry !== "string") return entry;
126
- const resolved = CONFIGS[entry];
127
- if (!resolved) throw new Error(`unknown extension package '${entry}'`);
128
- return resolveConfigPackages(resolved);
129
- });
130
- }
131
78
  /**
132
- * Recursively resolves string entries in the `extends` configuration option
133
- * with the resolved packages. Needed to workaround broken import resolution in
134
- * stylelint with pnpm.
79
+ * Resolves the name of an extension or plugin package to the absolute path of
80
+ * its entry file, as seen from this package.
135
81
  *
136
- * @template ConfigT
137
- * The exact type of the configuration (e.g. override config with files).
82
+ * StyleLint resolves package names in the options `extends` and `plugins`
83
+ * relative to the configuration file of the consumer project. With the strict
84
+ * `node_modules` layout of pnpm, the packages installed as dependencies of
85
+ * this package are not visible from there. An absolute path circumvents this
86
+ * resolution. StyleLint resolves nested `extends` entries of the referenced
87
+ * package relative to that package's own location, so the transitive packages
88
+ * do not need any special handling.
138
89
  *
139
- * @param config
140
- * The configuration to be resolved.
90
+ * @param name
91
+ * The name of the package to be resolved, optionally with a subpath (e.g.
92
+ * 'stylelint-config-standard-vue/scss').
141
93
  *
142
94
  * @returns
143
- * The passed configuration object with resolved extensions.
95
+ * The absolute path of the entry file of the package.
144
96
  */
145
- function resolveConfigPackages(config) {
146
- resolveEntries(config);
147
- config.overrides?.forEach(resolveEntries);
148
- return config;
97
+ function resolvePackage(name) {
98
+ return fileURLToPath(import.meta.resolve(name));
149
99
  }
150
100
  //#endregion
151
101
  //#region src/stylelint/index.ts
@@ -154,10 +104,11 @@ function resolveConfigPackages(config) {
154
104
  * entire project.
155
105
  *
156
106
  * @param options
157
- * Plugin configuration options.
107
+ * Project configuration options.
158
108
  *
159
109
  * @returns
160
- * The configuration object to be exported from `stylelint.config.js`.
110
+ * The configuration object to be exported from the project's configuration
111
+ * file (e.g. `stylelint.config.ts`).
161
112
  */
162
113
  function defineConfig(options) {
163
114
  const ignoreFiles = [
@@ -176,12 +127,12 @@ function defineConfig(options) {
176
127
  };
177
128
  const resolver = new PathResolver(options.root);
178
129
  const extensions = {
179
- base: ["stylelint-config-standard", "@stylistic/stylelint-config"],
180
- scss: ["stylelint-config-standard-scss"],
181
- less: ["stylelint-config-standard-less"],
182
- vue: [options.vue?.lang === "scss" ? "stylelint-config-standard-vue/scss" : "stylelint-config-standard-vue"]
130
+ base: [resolvePackage("stylelint-config-standard"), resolvePackage("@stylistic/stylelint-config")],
131
+ scss: [resolvePackage("stylelint-config-standard-scss")],
132
+ less: [resolvePackage("stylelint-config-standard-less")],
133
+ vue: [resolvePackage(options.vue?.lang === "scss" ? "stylelint-config-standard-vue/scss" : "stylelint-config-standard-vue")]
183
134
  };
184
- if (options.tailwind) extensions.base.push("stylelint-config-tailwindcss");
135
+ if (options.tailwind) extensions.base.push(resolvePackage("stylelint-config-tailwindcss"));
185
136
  const rules = {
186
137
  base: {
187
138
  "at-rule-empty-line-before": null,
@@ -239,7 +190,7 @@ function defineConfig(options) {
239
190
  plugins: license_header_default,
240
191
  rules: { "license-header/header": resolver.path(options.license) }
241
192
  });
242
- return resolveConfigPackages({
193
+ return {
243
194
  ignoreFiles,
244
195
  reportDescriptionlessDisables: null,
245
196
  reportInvalidScopeDisables: true,
@@ -248,7 +199,7 @@ function defineConfig(options) {
248
199
  extends: extensions.base,
249
200
  rules: rules.base,
250
201
  overrides
251
- });
202
+ };
252
203
  }
253
204
  //#endregion
254
205
  export { defineConfig };
@@ -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// functions ==================================================================\n\nconst promiseCache = new Map<string, Promise<string>>()\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","\nimport type { Config, Plugin } from 'stylelint'\nimport lessPlugin from 'stylelint-less'\nimport scssPlugin from 'stylelint-scss'\nimport htmlConfig from 'stylelint-config-html'\nimport recommendedConfig from 'stylelint-config-recommended'\nimport recommendedLessConfig from 'stylelint-config-recommended-less'\nimport recommendedScssConfig from 'stylelint-config-recommended-scss'\nimport recommendedVueConfig from 'stylelint-config-recommended-vue'\nimport recommendedVueScssConfig from 'stylelint-config-recommended-vue/scss'\nimport standardConfig from 'stylelint-config-standard'\nimport standardLessConfig from 'stylelint-config-standard-less'\nimport standardScssConfig from 'stylelint-config-standard-scss'\nimport standardVueConfig from 'stylelint-config-standard-vue'\nimport standardVueScssConfig from 'stylelint-config-standard-vue/scss'\nimport stylisticPlugin from '@stylistic/stylelint-plugin'\nimport stylisticConfig from '@stylistic/stylelint-config'\nimport tailwindConfig from 'stylelint-config-tailwindcss'\n\n// constants ==================================================================\n\nconst PLUGINS: Record<string, Plugin | undefined> = {\n '@stylistic/stylelint-plugin': stylisticPlugin,\n 'stylelint-less': lessPlugin,\n 'stylelint-scss': scssPlugin,\n}\n\nconst CONFIGS: Record<string, Config | undefined> = {\n '@stylistic/stylelint-config': stylisticConfig,\n 'stylelint-config-html': htmlConfig,\n 'stylelint-config-recommended': recommendedConfig,\n 'stylelint-config-recommended-less': recommendedLessConfig,\n 'stylelint-config-recommended-scss': recommendedScssConfig,\n 'stylelint-config-recommended-vue': recommendedVueConfig,\n 'stylelint-config-recommended-vue/scss': recommendedVueScssConfig,\n 'stylelint-config-standard': standardConfig,\n 'stylelint-config-standard-less': standardLessConfig,\n 'stylelint-config-standard-scss': standardScssConfig,\n 'stylelint-config-standard-vue': standardVueConfig,\n 'stylelint-config-standard-vue/scss': standardVueScssConfig,\n 'stylelint-config-tailwindcss': tailwindConfig,\n}\n\n// functions ==================================================================\n\n/**\n * Resolves string entries in the configuration options `plugins` and `extends`\n * to imported objects.\n *\n * @param config\n * The configuration to be resolved.\n */\nfunction resolveEntries(config: Config): void {\n\n // resolve string references to plugin packages\n config.plugins &&= [config.plugins].flat().map(entry => {\n if (typeof entry !== 'string') return entry\n const resolved = PLUGINS[entry]\n if (!resolved) throw new Error(`unknown plugin package '${entry}'`)\n return resolved\n })\n\n // resolve string references to extension packages\n // @ts-expect-error -- broken types\n config.extends &&= [config.extends].flat().map(entry => {\n if (typeof entry !== 'string') return entry\n const resolved = CONFIGS[entry]\n if (!resolved) throw new Error(`unknown extension package '${entry}'`)\n // recursively resolve extensions in imported package\n return resolveConfigPackages(resolved)\n })\n}\n\n/**\n * Recursively resolves string entries in the `extends` configuration option\n * with the resolved packages. Needed to workaround broken import resolution in\n * stylelint with pnpm.\n *\n * @template ConfigT\n * The exact type of the configuration (e.g. override config with files).\n *\n * @param config\n * The configuration to be resolved.\n *\n * @returns\n * The passed configuration object with resolved extensions.\n */\nexport function resolveConfigPackages<ConfigT extends Config>(config: ConfigT): ConfigT {\n resolveEntries(config)\n config.overrides?.forEach(resolveEntries)\n return config\n}\n","\nimport type { Config } from 'stylelint'\n\nimport licensePlugin from '@/stylelint/rules/license-header.ts'\nimport { resolveConfigPackages } 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 type of the string delimiter character.\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 parser plugin 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 project root containing the StyleLint configuration file.\n * Should 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 * source files. May be a path relative to the project root.\n */\n license?: string\n\n /**\n * Whether the project uses TailwindCSS. Causes to add the configuration\n * package `stylelint-config-tailwindcss`.\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 * Plugin configuration options.\n *\n * @returns\n * The configuration object to be exported from `stylelint.config.js`.\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\n const extensions = {\n base: [\n 'stylelint-config-standard',\n '@stylistic/stylelint-config',\n ],\n scss: [\n 'stylelint-config-standard-scss',\n ],\n less: [\n 'stylelint-config-standard-less',\n ],\n vue: [\n (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('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 resolveConfigPackages({\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;AAIA,MAAM,+BAAe,IAAI,IAA6B;;;;;;;;;;AAWtD,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;;;ACzE3F,MAAM,UAA8C;CA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AU;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,sBAAsB;EAG3B;EAGA,+BAA+B;EAC/B,4BAA4B;EAC5B,wBAAwB;EACxB,wBAAwB;EAGxB,SAAS,WAAW;EACpB,OAAO,MAAM;EACb;CACF,CAAC;AACH"}
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,YAA0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C;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"}
@@ -37,7 +37,7 @@ After the mandatory `options` parameters, the function can take multiple custom
37
37
 
38
38
  | Name | Type | Default | Description |
39
39
  | - | - | - | - |
40
- | `root` | `string` | _required_ | The URL of the project root containing the ESLint configuration file. Should usually be set to `import.meta.url`. |
40
+ | `root` | `string` | _required_ | The URL of the ESLint configuration file in the project root. Should usually be set to `import.meta.url`. |
41
41
  | `ignores` | `string[]` | `[]` | Glob patterns with all files and folders to be ignored by ESLint. This package already defines a few standard ignore globs (see below). |
42
42
  | `license` | `string` | `''` | Path to the template file containing the license header to be used in all source files (relative to `root`). |
43
43
  | `language` | `LanguageOptions` | | Configuration options for language and project setup. |
@@ -98,9 +98,9 @@ Each key in the `hierarchy` record is the arbitrary unique name of a package. Th
98
98
 
99
99
  | Name | Type | Default | Description |
100
100
  | - | - | - | - |
101
- | `files` | `string[]` | _required_ | Glob patterns selecting all source files that are part of the package. |
101
+ | `files` | `string[]` | _required_ | Glob patterns matching the module names (project-relative paths without file extension, with alias prefix if configured) of all modules in the package. |
102
102
  | `extends` | `string\|string[]` | `[]` | Specifies the names of all packages (dictionary keys of the option `hierarchy`) this package depends on. |
103
- | `optional` | `boolean` | `false` | Set to `true` to mark an optional package that may be missing in an installation. Such a package cannot be imported statically (with `import` statement) from a non-optional package, but can only be loaded dynamically at runtime (by calling `import()`). The rule will mark all static imports of optional code as an error. |
103
+ | `optional` | `boolean` | `false` | Set to `true` to mark an optional package that may be missing in an installation. Such a package cannot be imported statically (with `import` statement) from any other package, but can only be loaded dynamically at runtime (by calling `import()`). |
104
104
 
105
105
  Modules that are part of such a package may import any modules from the same package, or from packages it depends on (also recursively from their dependent packages).
106
106
 
@@ -29,13 +29,13 @@ function defineConfig(options: ProjectOptions): Config
29
29
 
30
30
  | Name | Type | Default | Description |
31
31
  | - | - | - | - |
32
- | `root` | `string` | _required_ | The URL of the project root containing the StyleLint configuration file. Should usually be set to `import.meta.url`. |
32
+ | `root` | `string` | _required_ | The URL of the StyleLint configuration file in the project root. Should usually be set to `import.meta.url`. |
33
33
  | `ignores` | `string[]` | `[]` | Glob patterns with all files to be ignored by StyleLint. |
34
34
  | `license` | `string` | `''` | Path to the template file containing the license header to be used in all source files (relative to `root`). |
35
- | `tailwind` | `boolean` | `false` | Whether the project uses TailwindCSS. Causes to add the configuration package [`stylelint-config-tailwindcss`](https://github.com/zhilidali/stylelint-config-tailwindcss). |
35
+ | `tailwind` | `boolean` | `false` | Whether the project uses TailwindCSS. If set, the configuration package [`stylelint-config-tailwindcss`](https://github.com/zhilidali/stylelint-config-tailwindcss) will be added. |
36
36
  | `stylistic` | `StylisticOptions` | | Configuration options for code style. |
37
37
  | `stylistic.indent` | `number` | `2` | Default indentation size (number of space characters). |
38
- | `stylistic.quotes` | `'single'\|'double'\|'off'` | `'single'` | The type of the string delimiter character. |
38
+ | `stylistic.quotes` | `'single'\|'double'\|'off'` | `'single'` | The quote character for string literals, or `'off'` to disable the quote check. |
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. |
@@ -56,7 +56,7 @@ Custom ignore globs passed in the options will be added to the built-in ignore l
56
56
  #### `defineConfig` Example
57
57
 
58
58
  ```ts
59
- // stylelint.config.js
59
+ // stylelint.config.ts
60
60
  import { defineConfig } from '@open-xchange/linter-presets/stylelint'
61
61
 
62
62
  export default defineConfig({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xchange/linter-presets",
3
- "version": "1.30.7",
3
+ "version": "1.31.1",
4
4
  "description": "Configuration presets for ESLint and StyleLint",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,11 +26,11 @@
26
26
  "CHANGELOG.*"
27
27
  ],
28
28
  "dependencies": {
29
- "@babel/core": "^8.0.6",
30
- "@babel/eslint-parser": "^8.0.6",
29
+ "@babel/core": "^8.0.7",
30
+ "@babel/eslint-parser": "^8.0.7",
31
31
  "@eslint-community/eslint-plugin-eslint-comments": "^4.8.1",
32
- "@eslint-react/eslint-plugin": "^5.23.1",
33
- "@eslint-react/kit": "^5.23.1",
32
+ "@eslint-react/eslint-plugin": "^5.28.6",
33
+ "@eslint-react/kit": "^5.28.6",
34
34
  "@eslint/compat": "^2.1.1",
35
35
  "@eslint/config-helpers": "^0.7.0",
36
36
  "@eslint/core": "^1.2.1",
@@ -42,22 +42,22 @@
42
42
  "@stylistic/stylelint-plugin": "^5.3.1",
43
43
  "@types/json-schema": "^7.0.15",
44
44
  "@types/picomatch": "^4.0.3",
45
- "@vitest/eslint-plugin": "^1.6.27",
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
48
  "empathic": "^2.1.0",
49
- "eslint-plugin-chai-expect": "^4.1.0",
49
+ "eslint-plugin-chai-expect": "^4.1.1",
50
50
  "eslint-plugin-codeceptjs": "^1.3.0",
51
51
  "eslint-plugin-depend": "^1.5.0",
52
52
  "eslint-plugin-eslint-plugin": "^7.6.2",
53
- "eslint-plugin-jest": "^29.16.6",
53
+ "eslint-plugin-jest": "^29.17.0",
54
54
  "eslint-plugin-jest-dom": "^5.10.1",
55
55
  "eslint-plugin-jest-extended": "^3.0.1",
56
- "eslint-plugin-jsdoc": "^65.0.1",
56
+ "eslint-plugin-jsdoc": "^65.4.1",
57
57
  "eslint-plugin-jsonc": "^3.4.2",
58
58
  "eslint-plugin-jsx-a11y": "^6.10.2",
59
59
  "eslint-plugin-license-header": "^0.9.0",
60
- "eslint-plugin-n": "^18.4.0",
60
+ "eslint-plugin-n": "^18.5.0",
61
61
  "eslint-plugin-no-unsanitized": "^4.1.5",
62
62
  "eslint-plugin-promise": "^7.3.0",
63
63
  "eslint-plugin-react-hooks": "^7.1.1",
@@ -65,8 +65,8 @@
65
65
  "eslint-plugin-regexp": "^3.3.1",
66
66
  "eslint-plugin-testing-library": "^7.16.2",
67
67
  "eslint-plugin-vue": "^10.11.1",
68
- "eslint-plugin-yml": "^3.8.1",
69
- "globals": "^17.12.0",
68
+ "eslint-plugin-yml": "^3.9.0",
69
+ "globals": "^17.13.0",
70
70
  "picomatch": "^4.0.7",
71
71
  "postcss-html": "^2.0.0",
72
72
  "stylelint-config-html": "^2.0.0",
@@ -79,20 +79,20 @@
79
79
  "stylelint-config-standard-scss": "^17.0.0",
80
80
  "stylelint-config-standard-vue": "^2.0.0",
81
81
  "stylelint-config-tailwindcss": "^1.0.1",
82
- "stylelint-less": "^4.2.1",
82
+ "stylelint-less": "^4.2.2",
83
83
  "stylelint-scss": "^7.3.0",
84
- "typescript-eslint": "^8.71.0"
84
+ "typescript-eslint": "^8.72.0"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@jest/globals": "^30.5.2",
88
88
  "@open-xchange/tsconfig": "^0.2.4",
89
89
  "@types/confusing-browser-globals": "^1.0.3",
90
90
  "@types/react": "^19.3.0",
91
- "@typescript-eslint/utils": "^8.71.0",
92
- "eslint": "^10.11.0",
91
+ "@typescript-eslint/utils": "^8.72.0",
92
+ "eslint": "^10.13.0",
93
93
  "jest": "^30.5.2",
94
- "stylelint": "^17.15.0",
95
- "vitest": "^5.0.3"
94
+ "stylelint": "^17.16.0",
95
+ "vitest": "^5.0.5"
96
96
  },
97
97
  "peerDependencies": {
98
98
  "eslint": "^9.35.0 || ^10.0.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolver-Nkg5OKUN.mjs","names":[],"sources":["../src/utils/resolver.ts"],"sourcesContent":["\nimport { dirname } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n// functions ==================================================================\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\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;;;;;CAMA,IAAI,OAAe;EACjB,OAAO,KAAK;CACd;;;;;;;;;;CAWA,KAAK,MAAsB;EACzB,OAAO,cAAc,IAAI,IAAI,MAAM,KAAK,IAAI,CAAC;CAC/C;AACF"}