99
1010import eslintConfigESLint from "eslint-config-eslint" ;
1111import eslintPlugin from "eslint-plugin-eslint-plugin" ;
12+ import globals from "globals" ;
1213import json from "@eslint/json" ;
1314import { defineConfig , globalIgnores } from "eslint/config" ;
14- import css from "./src/index.js" ;
1515
1616//-----------------------------------------------------------------------------
1717// Helpers
1818//-----------------------------------------------------------------------------
1919
20- const eslintPluginJSDoc = eslintConfigESLint . find (
21- config => config . plugins ?. jsdoc ,
22- ) . plugins . jsdoc ;
23-
2420const eslintPluginRulesRecommendedConfig =
2521 eslintPlugin . configs [ "flat/rules-recommended" ] ;
2622const eslintPluginTestsRecommendedConfig =
@@ -31,66 +27,38 @@ const eslintPluginTestsRecommendedConfig =
3127//-----------------------------------------------------------------------------
3228
3329export default defineConfig ( [
34- globalIgnores ( [
35- "**/tests/fixtures/" ,
36- "**/dist/" ,
37- "test.css" ,
38- "coverage/" ,
39- "src/build/" ,
40- ] ) ,
41-
42- ...eslintConfigESLint . map ( config => ( {
43- files : [ "**/*.js" ] ,
44- ...config ,
45- } ) ) ,
46- {
47- plugins : { json } ,
48- files : [ "**/*.json" , ".c8rc" ] ,
49- language : "json/json" ,
50- extends : [ "json/recommended" ] ,
51- } ,
30+ globalIgnores ( [ "coverage/" , "dist/" , "src/build/" ] , "css/global-ignores" ) ,
5231 {
32+ name : "css/js" ,
5333 files : [ "**/*.js" ] ,
34+ extends : [ eslintConfigESLint ] ,
5435 rules : {
55- // disable rules we don't want to use from eslint-config-eslint
5636 "no-undefined" : "off" ,
5737 "class-methods-use-this" : "off" ,
58-
59- // TODO: re-enable eslint-plugin-jsdoc rules
60- ...Object . fromEntries (
61- Object . keys ( eslintPluginJSDoc . rules ) . map ( name => [
62- `jsdoc/${ name } ` ,
63- "off" ,
64- ] ) ,
65- ) ,
6638 } ,
6739 } ,
6840 {
69- files : [ "**/tests/**" ] ,
41+ name : "css/tools" ,
42+ files : [ "tools/**/*.js" ] ,
43+ rules : {
44+ "no-console" : "off" ,
45+ } ,
46+ } ,
47+ {
48+ name : "css/tests" ,
49+ files : [ "tests/**/*.js" ] ,
50+ ignores : [ "tests/rules/*.js" ] ,
7051 languageOptions : {
7152 globals : {
72- describe : "readonly" ,
73- xdescribe : "readonly" ,
74- it : "readonly" ,
75- xit : "readonly" ,
76- beforeEach : "readonly" ,
77- afterEach : "readonly" ,
78- before : "readonly" ,
79- after : "readonly" ,
53+ ...globals . mocha ,
8054 } ,
8155 } ,
8256 } ,
8357 {
58+ name : "css/rules" ,
8459 files : [ "src/rules/*.js" ] ,
8560 extends : [ eslintPluginRulesRecommendedConfig ] ,
8661 rules : {
87- "eslint-plugin/require-meta-docs-url" : [
88- "error" ,
89- {
90- pattern :
91- "https://github.com/eslint/css/blob/main/docs/rules/{{name}}.md" ,
92- } ,
93- ] ,
9462 "eslint-plugin/require-meta-schema" : "off" , // `schema` defaults to []
9563 "eslint-plugin/prefer-placeholders" : "error" ,
9664 "eslint-plugin/prefer-replace-text" : "error" ,
@@ -99,9 +67,17 @@ export default defineConfig([
9967 "error" ,
10068 { pattern : "^(Enforce|Require|Disallow) .+[^. ]$" } ,
10169 ] ,
70+ "eslint-plugin/require-meta-docs-url" : [
71+ "error" ,
72+ {
73+ pattern :
74+ "https://github.com/eslint/css/blob/main/docs/rules/{{name}}.md" ,
75+ } ,
76+ ] ,
10277 } ,
10378 } ,
10479 {
80+ name : "css/rules-tests" ,
10581 files : [ "tests/rules/*.test.js" ] ,
10682 extends : [ eslintPluginTestsRecommendedConfig ] ,
10783 rules : {
@@ -122,15 +98,10 @@ export default defineConfig([
12298 } ,
12399 } ,
124100 {
125- files : [ "**/*.css" ] ,
126- language : "css/css" ,
127- plugins : { css } ,
128- extends : [ "css/recommended" ] ,
129- } ,
130- {
131- files : [ "tools/**/*.js" ] ,
132- rules : {
133- "no-console" : "off" ,
134- } ,
101+ name : "css/json" ,
102+ plugins : { json } ,
103+ files : [ "**/*.json" , ".c8rc" ] ,
104+ language : "json/json" ,
105+ extends : [ "json/recommended" ] ,
135106 } ,
136107] ) ;
0 commit comments