@kazupon/eslint-config 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,6 +26,7 @@ ESLint config for @kazupon
26
26
  - `yml`
27
27
  - `toml`
28
28
  - `markdown`
29
+ - `css`
29
30
  - Support primitive eslint flat configuration
30
31
  - Support overrides for built-in configurations
31
32
  - `rules`
@@ -107,7 +108,8 @@ Add the following settings to your `.vscode/settings.json`:
107
108
  "json5",
108
109
  "markdown",
109
110
  "yaml",
110
- "toml"
111
+ "toml",
112
+ "css"
111
113
  ],
112
114
  // Enable flat configuration
113
115
  "eslint.useFlatConfig": true
@@ -119,7 +121,7 @@ Add the following settings to your `.vscode/settings.json`:
119
121
  The following built-in preset configurations are supported:
120
122
 
121
123
  | Configuration | Powered by eslint plugin or package | Need to install eslint plugin or package? |
122
- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
124
+ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- | --- |
123
125
  | `javascript` | [`@eslint/js`](https://www.npmjs.com/package/@eslint/js) | no (built-in) |
124
126
  | `comments` | [`@eslint-community/eslint-plugin-eslint-comments`](https://www.npmjs.com/package/@eslint-community/eslint-plugin-eslint-comments) | no (built-in) |
125
127
  | `typescript` | [`typescript-eslint`](https://www.npmjs.com/package/typescript-eslint) | yes |
@@ -137,6 +139,7 @@ The following built-in preset configurations are supported:
137
139
  | `yml` | [`eslint-plugin-yml`](https://www.npmjs.com/package/eslint-plugin-yml) | yes |
138
140
  | `toml` | [`eslint-plugin-toml`](https://www.npmjs.com/package/eslint-plugin-toml) | yes |
139
141
  | `markdown` | [`@eslint/markdown`](https://www.npmjs.com/package/@eslint/markdown) | yes |
142
+ | `css` | [`@eslint/css`](https://www.npmjs.com/package/@eslint/css) | yes | k |
140
143
 
141
144
  You can use `import` syntax:
142
145
 
package/dist/index.d.ts CHANGED
@@ -81,6 +81,50 @@ type EslintCommunityEslintCommentsRequireDescription = [] | [
81
81
  }
82
82
  ];
83
83
 
84
+ interface CssRules {
85
+ /**
86
+ * Disallow duplicate @import rules
87
+ * @see https://github.com/eslint/css/blob/main/docs/rules/no-duplicate-imports.md
88
+ */
89
+ 'css/no-duplicate-imports'?: Linter.RuleEntry<[]>;
90
+ /**
91
+ * Disallow empty blocks
92
+ * @see https://github.com/eslint/css/blob/main/docs/rules/no-empty-blocks.md
93
+ */
94
+ 'css/no-empty-blocks'?: Linter.RuleEntry<[]>;
95
+ /**
96
+ * Disallow invalid at-rules
97
+ * @see https://github.com/eslint/css/blob/main/docs/rules/no-invalid-at-rules.md
98
+ */
99
+ 'css/no-invalid-at-rules'?: Linter.RuleEntry<[]>;
100
+ /**
101
+ * Disallow invalid properties
102
+ * @see https://github.com/eslint/css/blob/main/docs/rules/no-invalid-properties.md
103
+ */
104
+ 'css/no-invalid-properties'?: Linter.RuleEntry<[]>;
105
+ /**
106
+ * Enforce the use of baseline features
107
+ */
108
+ 'css/require-baseline'?: Linter.RuleEntry<CssRequireBaseline>;
109
+ /**
110
+ * Require use of layers
111
+ * @see https://github.com/eslint/css/blob/main/docs/rules/use-layers.md
112
+ */
113
+ 'css/use-layers'?: Linter.RuleEntry<CssUseLayers>;
114
+ }
115
+ type CssRequireBaseline = [] | [
116
+ {
117
+ available?: ("widely" | "newly");
118
+ }
119
+ ];
120
+ type CssUseLayers = [] | [
121
+ {
122
+ allowUnnamedLayers?: boolean;
123
+ requireImportLayers?: boolean;
124
+ layerNamePattern?: string;
125
+ }
126
+ ];
127
+
84
128
  interface ImportsRules {
85
129
  /**
86
130
  * Enforce or ban the use of inline type-only markers for named imports.
@@ -13802,7 +13846,7 @@ type YmlSpacedComment = [] | [("always" | "never")] | [
13802
13846
 
13803
13847
  declare module 'eslint' {
13804
13848
  namespace Linter {
13805
- interface RulesRecord extends CommentsRules, ImportsRules, JavascriptRules, JsdocRules, JsoncRules, MarkdownRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VitestRules, VueRules, YmlRules {
13849
+ interface RulesRecord extends CommentsRules, CssRules, ImportsRules, JavascriptRules, JsdocRules, JsoncRules, MarkdownRules, PrettierRules, PromiseRules, ReactRules, RegexpRules, SvelteRules, TomlRules, TypescriptRules, UnicornRules, VitestRules, VueRules, YmlRules {
13806
13850
  }
13807
13851
  }
13808
13852
  }
@@ -13821,6 +13865,32 @@ interface CommentsOptions {
13821
13865
  */
13822
13866
  declare function comments(options?: CommentsOptions & OverridesOptions<CommentsRules>): Promise<Linter.Config[]>;
13823
13867
 
13868
+ /**
13869
+ * eslint css configuration options
13870
+ */
13871
+ interface CssOptions {
13872
+ /**
13873
+ * whether to enable strict mode
13874
+ * @see https://github.com/eslint/css?tab=readme-ov-file#tolerant-mode
13875
+ * @default false
13876
+ */
13877
+ tolerant?: boolean;
13878
+ /**
13879
+ * whether to enable custom syntax
13880
+ * @description if 'tailwind', it will enable [Tailwind Syntax](https://github.com/eslint/css?tab=readme-ov-file#configuring-tailwind-syntax), otherwise it will enable [custom syntax](https://github.com/eslint/css?tab=readme-ov-file#configuring-custom-syntax)
13881
+ * @default false
13882
+ */
13883
+ customSyntax?: false | 'tailwind' | Record<string, any>;
13884
+ }
13885
+ /**
13886
+ * `@eslint/css` and overrides configuration options
13887
+ * @param {CssOptions & OverridesOptions} options
13888
+ * eslint css configuration options
13889
+ * @returns {Promise<Linter.Config[]>}
13890
+ * eslint flat configurations with `@eslint/css` and overrides
13891
+ */
13892
+ declare function css(options?: CssOptions & OverridesOptions<CssRules>): Promise<Linter.Config[]>;
13893
+
13824
13894
  /**
13825
13895
  * imports configuration options
13826
13896
  */
@@ -14177,4 +14247,4 @@ interface YmlOptions {
14177
14247
  declare function yml(options?: YmlOptions & OverridesOptions<YmlRules>): Promise<Linter.Config[]>;
14178
14248
  declare const yaml: typeof yml;
14179
14249
 
14180
- export { type CommentsOptions, type CommentsRules, type ImportsOptions, type ImportsRules, type JavaScriptOptions, type JavascriptRules, type JsDocumentOptions, type JsdocRules, type JsoncOptions, type JsoncRules, type MarkdownOptions, type MarkdownRules, type OverridesOptions, type PrettierOptions, type PrettierRules, type PromiseOptions, type PromiseRules, type ReactOptions, type ReactRules, type RegexpOptions, type RegexpRules, type SvelteRules, type SvelteScriptOptions, type TomlOptions, type TomlRules, type TypeScriptOptions, type TypeScriptParserOptions, type TypescriptRules, type UnicornOptions, type UnicornRules, type VitestOptions, type VitestRules, type VueRules, type VueScriptOptions, type YmlOptions, type YmlRules, comments, defineConfig, imports, javascript, jsdoc, jsonc, markdown, md, prettier, promise, react, regexp, svelte, toml, typescript, unicorn, vitest, vue, yaml, yml };
14250
+ export { type CommentsOptions, type CommentsRules, type CssOptions, type CssRules, type ImportsOptions, type ImportsRules, type JavaScriptOptions, type JavascriptRules, type JsDocumentOptions, type JsdocRules, type JsoncOptions, type JsoncRules, type MarkdownOptions, type MarkdownRules, type OverridesOptions, type PrettierOptions, type PrettierRules, type PromiseOptions, type PromiseRules, type ReactOptions, type ReactRules, type RegexpOptions, type RegexpRules, type SvelteRules, type SvelteScriptOptions, type TomlOptions, type TomlRules, type TypeScriptOptions, type TypeScriptParserOptions, type TypescriptRules, type UnicornOptions, type UnicornRules, type VitestOptions, type VitestRules, type VueRules, type VueScriptOptions, type YmlOptions, type YmlRules, comments, css, defineConfig, imports, javascript, jsdoc, jsonc, markdown, md, prettier, promise, react, regexp, svelte, toml, typescript, unicorn, vitest, vue, yaml, yml };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { FlatConfigComposer } from "eslint-flat-config-utils";
2
2
  import { interopDefault } from "@kazupon/jts-utils/module";
3
+ import { isObject } from "@kazupon/jts-utils/object";
3
4
  import globals from "globals";
4
5
 
5
6
  //#region src/config.ts
@@ -22,6 +23,7 @@ const GLOB_TOML = "**/*.toml";
22
23
  const GLOB_VUE = "**/*.vue";
23
24
  const GLOB_SVELTE = "**/*.svelte";
24
25
  const GLOB_MARKDOWN = "**/*.md";
26
+ const GLOB_CSS = "**/*.css";
25
27
  const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
26
28
  const GLOB_TESTS = [
27
29
  `**/test/**/*.${GLOB_SRC_EXT}`,
@@ -72,6 +74,33 @@ async function comments(options = {}) {
72
74
  }];
73
75
  }
74
76
 
77
+ //#endregion
78
+ //#region src/configs/css.ts
79
+ async function css(options = {}) {
80
+ const { rules: overrideRules = {} } = options;
81
+ const tolerant = !!options.tolerant;
82
+ const customSyntax = !!options.customSyntax;
83
+ const css$1 = await loadPlugin("@eslint/css");
84
+ const core = {
85
+ files: [GLOB_CSS],
86
+ language: "css/css",
87
+ ...css$1.configs["recommended"]
88
+ };
89
+ if (tolerant) core.languageOptions = { tolerant };
90
+ if (customSyntax) {
91
+ core.languageOptions = core.languageOptions || {};
92
+ if (typeof customSyntax === "string" && customSyntax === "tailwind") {
93
+ const { tailwindSyntax } = await loadPlugin("@eslint/css/syntax");
94
+ core.languageOptions.customSyntax = tailwindSyntax;
95
+ } else if (isObject(customSyntax)) core.languageOptions.customSyntax = customSyntax;
96
+ }
97
+ return [core, {
98
+ name: "@kazupon/css",
99
+ files: [GLOB_CSS],
100
+ rules: { ...overrideRules }
101
+ }];
102
+ }
103
+
75
104
  //#endregion
76
105
  //#region src/configs/imports.ts
77
106
  const IMPORTS_FILES = [
@@ -613,4 +642,4 @@ async function yml(options = {}) {
613
642
  const yaml = yml;
614
643
 
615
644
  //#endregion
616
- export { comments, defineConfig, imports, javascript, jsdoc, jsonc, markdown, md, prettier, promise, react, regexp, svelte, toml, typescript, unicorn, vitest, vue, yaml, yml };
645
+ export { comments, css, defineConfig, imports, javascript, jsdoc, jsonc, markdown, md, prettier, promise, react, regexp, svelte, toml, typescript, unicorn, vitest, vue, yaml, yml };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kazupon/eslint-config",
3
3
  "description": "ESLint config for @kazupon",
4
- "version": "0.20.0",
4
+ "version": "0.21.0",
5
5
  "author": {
6
6
  "email": "kawakazu80@gmail.com",
7
7
  "name": "kazuya kawaguchi"
@@ -56,6 +56,7 @@
56
56
  "globals": "^16.0.0"
57
57
  },
58
58
  "peerDependencies": {
59
+ "@eslint/css": ">=0.4.0",
59
60
  "@eslint/markdown": ">=6.1.0",
60
61
  "@vitest/eslint-plugin": ">=1.0.0",
61
62
  "eslint": ">=8.56.0 || >=9.0.0",
@@ -82,6 +83,9 @@
82
83
  "typescript-eslint": ">=7.0.0"
83
84
  },
84
85
  "peerDependenciesMeta": {
86
+ "@eslint/css": {
87
+ "optional": true
88
+ },
85
89
  "@eslint/markdown": {
86
90
  "optional": true
87
91
  },
@@ -153,6 +157,7 @@
153
157
  }
154
158
  },
155
159
  "devDependencies": {
160
+ "@eslint/css": "^0.4.0",
156
161
  "@eslint/markdown": "^6.2.2",
157
162
  "@kazupon/prettier-config": "^0.1.1",
158
163
  "@types/eslint": "^9.6.1",