@open-xchange/linter-presets 1.27.0 → 1.27.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.
- package/CHANGELOG.md +4 -0
- package/dist/stylelint/index.mjs +11 -11
- package/dist/stylelint/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/stylelint/index.mjs
CHANGED
|
@@ -29,6 +29,7 @@ function defineConfig(options) {
|
|
|
29
29
|
};
|
|
30
30
|
const resolver = new PathResolver(options.root);
|
|
31
31
|
const plugins = [];
|
|
32
|
+
const overrides = [];
|
|
32
33
|
const rules = {
|
|
33
34
|
base: {
|
|
34
35
|
"at-rule-empty-line-before": null,
|
|
@@ -62,10 +63,15 @@ function defineConfig(options) {
|
|
|
62
63
|
"@stylistic/selector-list-comma-newline-after": null,
|
|
63
64
|
"@stylistic/string-quotes": stylistic.quotes === "off" ? null : [stylistic.quotes, { avoidEscape: true }]
|
|
64
65
|
});
|
|
65
|
-
if (options.license) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
if (options.license) overrides.push({
|
|
67
|
+
files: ["**/*.{css,scss,less}"],
|
|
68
|
+
plugins: [licensePlugin],
|
|
69
|
+
rules: { "plugin/license-header": [true, { license: resolver.path(options.license) }] }
|
|
70
|
+
});
|
|
71
|
+
if (options.vue?.rules) overrides.push({
|
|
72
|
+
files: ["**/*.vue"],
|
|
73
|
+
rules: options.vue.rules
|
|
74
|
+
});
|
|
69
75
|
if (options.rules) for (const [name, rule] of Object.entries(options.rules)) {
|
|
70
76
|
const key = name.split("/")[0];
|
|
71
77
|
(rules[key] ?? rules.base)[name] = rule;
|
|
@@ -90,13 +96,7 @@ function defineConfig(options) {
|
|
|
90
96
|
extends: ["stylelint-config-standard-less"],
|
|
91
97
|
rules: rules.less
|
|
92
98
|
},
|
|
93
|
-
|
|
94
|
-
files: ["**/*.vue"],
|
|
95
|
-
rules: {
|
|
96
|
-
"plugin/license-header": null,
|
|
97
|
-
...options.vue?.rules
|
|
98
|
-
}
|
|
99
|
-
}
|
|
99
|
+
...overrides
|
|
100
100
|
]
|
|
101
101
|
};
|
|
102
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/stylelint/index.ts"],"sourcesContent":["\nimport type { Config, ConfigRuleSettings, Plugin } from 'stylelint'\nimport licensePlugin from 'stylelint-plugin-license-header'\nimport stylisticPlugin from '@stylistic/stylelint-plugin'\n\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 to be added to the global 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 * 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.\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 // all plugins to be loaded\n const plugins: Plugin[] = []\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 },\n scss: {\n 'scss/dollar-variable-empty-line-before': null,\n 'scss/double-slash-comment-empty-line-before': null,\n },\n less: {},\n }\n\n // @stylistic plugin\n plugins.push(stylisticPlugin)\n Object.assign(rules.base, {\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\n // license-header plugin\n if (options.license) {\n
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/stylelint/index.ts"],"sourcesContent":["\nimport type { Config, ConfigRuleSettings, Plugin } from 'stylelint'\nimport licensePlugin from 'stylelint-plugin-license-header'\nimport stylisticPlugin from '@stylistic/stylelint-plugin'\n\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 to be added to the global 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 * 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.\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 // all plugins to be loaded\n const plugins: Plugin[] = []\n\n // custom overrides\n const overrides: Config['overrides'] = []\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 },\n scss: {\n 'scss/dollar-variable-empty-line-before': null,\n 'scss/double-slash-comment-empty-line-before': null,\n },\n less: {},\n }\n\n // @stylistic plugin\n plugins.push(stylisticPlugin)\n Object.assign(rules.base, {\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\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 'plugin/license-header': [true, { license: resolver.path(options.license) }],\n },\n })\n }\n\n // '.vue' files\n if (options.vue?.rules) {\n overrides.push({\n files: ['**/*.vue'],\n rules: 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 return {\n\n // ignore certain files and folders\n ignoreFiles,\n\n // language plugins\n plugins,\n\n // add recommended configurations\n extends: [\n '@stylistic/stylelint-config',\n (options.vue?.lang === 'scss') ? 'stylelint-config-standard-vue/scss' : 'stylelint-config-standard-vue',\n ],\n\n // rules for all language types\n rules: rules.base,\n\n // check inline directives\n reportDescriptionlessDisables: null,\n reportInvalidScopeDisables: true,\n reportNeedlessDisables: true,\n reportUnscopedDisables: true,\n\n // overrides for custom languages\n overrides: [\n\n // '.scss' files\n {\n files: ['**/*.scss'],\n extends: ['stylelint-config-standard-scss'],\n rules: rules.scss,\n },\n\n // '.less' files\n {\n files: ['**/*.less'],\n extends: ['stylelint-config-standard-less'],\n rules: rules.less,\n },\n\n ...overrides,\n ],\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA6GA,SAAgB,aAAa,SAAiC;CAE5D,MAAM,cAAwB;EAC5B;EACA;EACA;EACA;EACA;EACA;EACA,GAAI,QAAQ,WAAW,CAAC;CAC1B;CAGA,MAAM,YAA8B;EAClC,QAAQ;EACR,QAAQ;EACR,GAAG,QAAQ;CACb;CAGA,MAAM,WAAW,IAAI,aAAa,QAAQ,IAAI;CAG9C,MAAM,UAAoB,CAAC;CAG3B,MAAM,YAAiC,CAAC;CAGxC,MAAM,QAAoC;EACxC,MAAM;GACJ,6BAA6B;GAC7B,2BAA2B,CAAC,UAAU,E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