@open-xchange/linter-presets 1.30.1 → 1.30.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +8 -2
- package/dist/eslint/index.d.mts +5 -5
- package/dist/eslint/index.d.mts.map +1 -1
- package/dist/eslint/index.mjs +5 -2
- package/dist/eslint/index.mjs.map +1 -1
- package/dist/stylelint/index.d.mts +6 -7
- package/dist/stylelint/index.d.mts.map +1 -1
- package/dist/stylelint/index.mjs.map +1 -1
- package/docs/eslint/README.md +5 -2
- package/docs/eslint/env/eslint.md +1 -1
- package/docs/stylelint/README.md +7 -3
- package/package.json +15 -27
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Config
|
|
1
|
+
import { Config } from "stylelint";
|
|
2
2
|
//#region src/stylelint/index.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for multiple rules.
|
|
5
5
|
*/
|
|
6
|
-
type RuleRecord =
|
|
6
|
+
export type RuleRecord = NonNullable<Config['rules']>;
|
|
7
7
|
/**
|
|
8
8
|
* Configuration options for StyleLint code style rules.
|
|
9
9
|
*/
|
|
10
|
-
interface StylisticOptions {
|
|
10
|
+
export interface StylisticOptions {
|
|
11
11
|
/**
|
|
12
12
|
* Default indentation size (number of space characters).
|
|
13
13
|
*
|
|
@@ -24,7 +24,7 @@ interface StylisticOptions {
|
|
|
24
24
|
/**
|
|
25
25
|
* Configuration options for linting vue files.
|
|
26
26
|
*/
|
|
27
|
-
interface VueOptions {
|
|
27
|
+
export interface VueOptions {
|
|
28
28
|
/**
|
|
29
29
|
* The language parser plugin to be used.
|
|
30
30
|
*
|
|
@@ -40,7 +40,7 @@ interface VueOptions {
|
|
|
40
40
|
/**
|
|
41
41
|
* Configuration options for linting the entire project with StyleLint.
|
|
42
42
|
*/
|
|
43
|
-
interface ProjectOptions {
|
|
43
|
+
export interface ProjectOptions {
|
|
44
44
|
/**
|
|
45
45
|
* The URL of the project root containing the StyleLint configuration file.
|
|
46
46
|
* Should usually be set to `import.meta.url`.
|
|
@@ -86,7 +86,6 @@ interface ProjectOptions {
|
|
|
86
86
|
* @returns
|
|
87
87
|
* The configuration object to be exported from `stylelint.config.js`.
|
|
88
88
|
*/
|
|
89
|
-
declare function defineConfig(options: ProjectOptions): Config;
|
|
89
|
+
export declare function defineConfig(options: ProjectOptions): Config;
|
|
90
90
|
//#endregion
|
|
91
|
-
export { ProjectOptions, RuleRecord, StylisticOptions, VueOptions, defineConfig };
|
|
92
91
|
//# 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":";;;;;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 +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.open-xchange.com/fspd/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, ConfigRuleSettings } 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 = Record<string, ConfigRuleSettings<unknown, object>>\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\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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AGD,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.open-xchange.com/fspd/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,W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,CAAC,eAAe,EAAE,CAAC;GAC1E,8BAA8B;GAC9B,kCAAkC;GAClC,gDAAgD;GAChD,4BAA6B,UAAU,WAAW,QAAS,OAAO,CAAC,UAAU,QAAQ,EAAE,aAAa,KAAK,CAAC;EAC5G;EACA,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,sBAAsB;EAG3B;EAGA,+BAA+B;EAC/B,4BAA4B;EAC5B,wBAAwB;EACxB,wBAAwB;EAGxB,SAAS,WAAW;EACpB,OAAO,MAAM;EACb;CACF,CAAC;AACH"}
|
package/docs/eslint/README.md
CHANGED
|
@@ -37,8 +37,9 @@ 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
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). |
|
|
41
|
-
| `license` | `string` | `''` |
|
|
42
|
+
| `license` | `string` | `''` | Path to the template file containing the license header to be used in all source files (relative to `root`). |
|
|
42
43
|
| `language` | `LanguageOptions` | | Configuration options for language and project setup. |
|
|
43
44
|
| `language.ecmaVersion` | `number\|'latest'` | `'latest'` | The ECMAScript version to be used in the project (version or year). |
|
|
44
45
|
| `language.sourceType` | `'module'\|'commonjs'` | `'module'` | Specifies how to treat `.js`, `.jsx`, `.ts`, and `.tsx` files. |
|
|
@@ -55,6 +56,7 @@ After the mandatory `options` parameters, the function can take multiple custom
|
|
|
55
56
|
| `stylistic.semi` | `'always'\|'never'\|'off'` | `'never'` | Specifies whether to require semicolons following all statements (`'always'`), or to force to omit semicolons if possible according to ASI rules (`'never'`). |
|
|
56
57
|
| `stylistic.quotes` | `'single'\|'double'\|'off'` | `'single'` | The type of the string delimiter character. |
|
|
57
58
|
| `stylistic.dangle` | `'always'\|'never'\|'off'` | `'always'` | Specifies how to treat dangling commas in multiline lists. |
|
|
59
|
+
| `stylistic.funcSpacing` | `'always'\|'never'\|'off'` | `'off'` | Specifies whether to expect whitespace between function names and parentheses. |
|
|
58
60
|
| `vue` | `VueOptions` | `{}` | Additional options for Vue specific rules. |
|
|
59
61
|
| `vue.globalDirectives` | `string[]` | `[]` | Names of all globally registered directives to be ignored by the rule [`vue/no-undef-directives`](https://eslint.vuejs.org/rules/no-undef-directives.html) (without 'v-' prefix). |
|
|
60
62
|
| `rules` | `RulesConfig` | `{}` | Additional linter rules to be added to the global configuration. |
|
|
@@ -66,9 +68,9 @@ This package defines ignore globs for the following files and directories:
|
|
|
66
68
|
- `*/.yarn` (internal setup files of Yarn v2+)
|
|
67
69
|
- `dist` (standard build output directory)
|
|
68
70
|
- `output` (output directory for tests etc.)
|
|
71
|
+
- `coverage` (Vitest coverage results)
|
|
69
72
|
- `vite.config.ts.*.mjs` (intermediate files of Vite dev server)
|
|
70
73
|
- `gitlab-ci` and `.gitlab-ci.yml` (GitLab CI configuration files)
|
|
71
|
-
- `coverage` (Vitest coverage results)
|
|
72
74
|
- `.nuxt` and `.output` (NuxtJS output directories)
|
|
73
75
|
|
|
74
76
|
Custom ignore globs passed in the options will be added to the built-in ignore list.
|
|
@@ -80,6 +82,7 @@ Custom ignore globs passed in the options will be added to the built-in ignore l
|
|
|
80
82
|
import { defineConfig } from '@open-xchange/linter-presets/eslint'
|
|
81
83
|
|
|
82
84
|
export default defineConfig({
|
|
85
|
+
root: import.meta.url,
|
|
83
86
|
ignores: ['external/**/*.yaml'],
|
|
84
87
|
language: { ecmaVersion: 2024, sourceType: 'commonjs' },
|
|
85
88
|
license: './license.txt',
|
package/docs/stylelint/README.md
CHANGED
|
@@ -22,21 +22,22 @@ Generates standard configuration targeting the source files in the entire projec
|
|
|
22
22
|
```ts
|
|
23
23
|
import type { Config } from 'stylelint'
|
|
24
24
|
|
|
25
|
-
function defineConfig(options
|
|
25
|
+
function defineConfig(options: ProjectOptions): Config
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
#### `defineConfig` Options
|
|
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
33
|
| `ignores` | `string[]` | `[]` | Glob patterns with all files to be ignored by StyleLint. |
|
|
33
|
-
| `license` | `string` | `''` |
|
|
34
|
+
| `license` | `string` | `''` | Path to the template file containing the license header to be used in all source files (relative to `root`). |
|
|
34
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
36
|
| `stylistic` | `StylisticOptions` | | Configuration options for code style. |
|
|
36
37
|
| `stylistic.indent` | `number` | `2` | Default indentation size (number of space characters). |
|
|
37
38
|
| `stylistic.quotes` | `'single'\|'double'\|'off'` | `'single'` | The type of the string delimiter character. |
|
|
38
39
|
| `vue` | `VueOptions` | | Configuration options for linting `<style>` elements in Vue single component files. |
|
|
39
|
-
| `vue.lang` | `'css'
|
|
40
|
+
| `vue.lang` | `'css'\|'scss'` | `'css'` | The style language used in the Vue files. |
|
|
40
41
|
| `vue.rules` | `RuleRecord` | `{}` | Additional linter rules for Vue files. |
|
|
41
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
43
|
|
|
@@ -50,6 +51,8 @@ This package defines ignore globs for the following files and directories:
|
|
|
50
51
|
- `coverage/**/*` (Vitest coverage results)
|
|
51
52
|
- `.nuxt/**/*` and `.output/**/*` (NuxtJS output directories)
|
|
52
53
|
|
|
54
|
+
Custom ignore globs passed in the options will be added to the built-in ignore list.
|
|
55
|
+
|
|
53
56
|
#### `defineConfig` Example
|
|
54
57
|
|
|
55
58
|
```ts
|
|
@@ -57,6 +60,7 @@ This package defines ignore globs for the following files and directories:
|
|
|
57
60
|
import { defineConfig } from '@open-xchange/linter-presets/stylelint'
|
|
58
61
|
|
|
59
62
|
export default defineConfig({
|
|
63
|
+
root: import.meta.url,
|
|
60
64
|
ignores: ['external/**/*.scss'],
|
|
61
65
|
license: './license.txt',
|
|
62
66
|
stylistic: { indent: 2, quotes: 'single' },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-xchange/linter-presets",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.3",
|
|
4
4
|
"description": "Configuration presets for ESLint and StyleLint",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/core": "^8.0.1",
|
|
30
30
|
"@babel/eslint-parser": "^8.0.1",
|
|
31
|
-
"@eslint-community/eslint-plugin-eslint-comments": "^4.
|
|
32
|
-
"@eslint-react/eslint-plugin": "^5.
|
|
33
|
-
"@eslint-react/kit": "^5.
|
|
34
|
-
"@eslint/compat": "^2.1.
|
|
31
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.8.0",
|
|
32
|
+
"@eslint-react/eslint-plugin": "^5.19.0",
|
|
33
|
+
"@eslint-react/kit": "^5.19.0",
|
|
34
|
+
"@eslint/compat": "^2.1.1",
|
|
35
35
|
"@eslint/config-helpers": "^0.7.0",
|
|
36
36
|
"@eslint/core": "^1.2.1",
|
|
37
37
|
"@eslint/js": "^10.0.1",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"eslint-plugin-jest": "^29.16.6",
|
|
54
54
|
"eslint-plugin-jest-dom": "^5.10.1",
|
|
55
55
|
"eslint-plugin-jest-extended": "^3.0.1",
|
|
56
|
-
"eslint-plugin-jsdoc": "^64.3.
|
|
56
|
+
"eslint-plugin-jsdoc": "^64.3.6",
|
|
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",
|
|
@@ -61,10 +61,10 @@
|
|
|
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",
|
|
64
|
-
"eslint-plugin-react-refresh": "^0.5.
|
|
65
|
-
"eslint-plugin-regexp": "^3.
|
|
64
|
+
"eslint-plugin-react-refresh": "^0.5.6",
|
|
65
|
+
"eslint-plugin-regexp": "^3.3.0",
|
|
66
66
|
"eslint-plugin-testing-library": "^7.16.2",
|
|
67
|
-
"eslint-plugin-vue": "^10.
|
|
67
|
+
"eslint-plugin-vue": "^10.11.0",
|
|
68
68
|
"eslint-plugin-yml": "^3.8.1",
|
|
69
69
|
"globals": "^17.12.0",
|
|
70
70
|
"picomatch": "^4.0.7",
|
|
@@ -81,35 +81,29 @@
|
|
|
81
81
|
"stylelint-config-tailwindcss": "^1.0.1",
|
|
82
82
|
"stylelint-less": "^4.2.1",
|
|
83
83
|
"stylelint-scss": "^7.2.0",
|
|
84
|
-
"typescript-eslint": "^8.
|
|
84
|
+
"typescript-eslint": "^8.70.0"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@jest/globals": "^30.5.1",
|
|
88
88
|
"@open-xchange/tsconfig": "^0.2.2",
|
|
89
89
|
"@types/confusing-browser-globals": "^1.0.3",
|
|
90
90
|
"@types/react": "^19.2.18",
|
|
91
|
-
"@typescript-eslint/utils": "^8.
|
|
92
|
-
"eslint": "^10.
|
|
91
|
+
"@typescript-eslint/utils": "^8.70.0",
|
|
92
|
+
"eslint": "^10.10.0",
|
|
93
93
|
"jest": "^30.5.1",
|
|
94
|
-
"stylelint": "^17.
|
|
95
|
-
"
|
|
94
|
+
"stylelint": "^17.15.0",
|
|
95
|
+
"vitest": "^5.0.0"
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
98
98
|
"eslint": "^9.35.0 || ^10.0.0",
|
|
99
|
-
"jest": "^29.7.0 || ^30.0.0",
|
|
100
99
|
"postcss": "^8.4.0",
|
|
101
100
|
"stylelint": "^17.1.0",
|
|
102
|
-
"typescript": "^5.9.0 || ^6.0.0 || ^7.0.0"
|
|
103
|
-
"vitest": "^3.0.0 || ^4.0.0",
|
|
104
|
-
"vue": "^3.5.0"
|
|
101
|
+
"typescript": "^5.9.0 || ^6.0.0 || ^7.0.0"
|
|
105
102
|
},
|
|
106
103
|
"peerDependenciesMeta": {
|
|
107
104
|
"eslint": {
|
|
108
105
|
"optional": true
|
|
109
106
|
},
|
|
110
|
-
"jest": {
|
|
111
|
-
"optional": true
|
|
112
|
-
},
|
|
113
107
|
"postcss": {
|
|
114
108
|
"optional": true
|
|
115
109
|
},
|
|
@@ -118,12 +112,6 @@
|
|
|
118
112
|
},
|
|
119
113
|
"typescript": {
|
|
120
114
|
"optional": true
|
|
121
|
-
},
|
|
122
|
-
"vitest": {
|
|
123
|
-
"optional": true
|
|
124
|
-
},
|
|
125
|
-
"vue": {
|
|
126
|
-
"optional": true
|
|
127
115
|
}
|
|
128
116
|
},
|
|
129
117
|
"scripts": {
|