Skip to content

Commit deefc38

Browse files
authored
chore: restore eslint-plugin-jsdoc rules (#324)
* chore: restore eslint-plugin-jsdoc rules * add `coverage/` to global ignores
1 parent 5167be9 commit deefc38

File tree

6 files changed

+39
-67
lines changed

6 files changed

+39
-67
lines changed

eslint.config.js

Lines changed: 29 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,14 @@
99

1010
import eslintConfigESLint from "eslint-config-eslint";
1111
import eslintPlugin from "eslint-plugin-eslint-plugin";
12+
import globals from "globals";
1213
import json from "@eslint/json";
1314
import { 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-
2420
const eslintPluginRulesRecommendedConfig =
2521
eslintPlugin.configs["flat/rules-recommended"];
2622
const eslintPluginTestsRecommendedConfig =
@@ -31,66 +27,38 @@ const eslintPluginTestsRecommendedConfig =
3127
//-----------------------------------------------------------------------------
3228

3329
export 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
]);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"eslint": "^9.36.0",
9696
"eslint-config-eslint": "^13.0.0",
9797
"eslint-plugin-eslint-plugin": "^6.3.2",
98+
"globals": "^16.5.0",
9899
"lint-staged": "^15.2.7",
99100
"mdast-util-from-markdown": "^2.0.2",
100101
"mdn-data": "^2.25.0",

src/languages/css-language.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ const blockCloserTokenTypes = new Map([
5454
/**
5555
* Recursively replaces all function values in an object with boolean true.
5656
* Used to make objects serializable for JSON output.
57-
*
5857
* @param {Record<string,any>|unknown[]|unknown} object The object to process.
5958
* @returns {Record<string,any>|unknown[]|unknown} A copy of the object with all functions replaced by true.
6059
*/

src/rules/no-invalid-at-rules.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export default {
100100
* - Ensures the rule has a prelude
101101
* - Validates the prelude matches the expected pattern
102102
* @param {AtrulePlain} node The node representing the rule.
103+
* @returns {void}
103104
*/
104105
function validateCharsetRule(node) {
105106
const { name, prelude, loc } = node;

src/rules/no-invalid-properties.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ const varFunctionPattern = /var\(\s*(--[^,\s)]+)\s*(?:,([\s\S]+))?\)/iu;
3232

3333
/**
3434
* Parses a var() function text and extracts the custom property name and fallback.
35-
* @param {string} text
36-
* @returns {{ name: string, fallbackText: string | null } | null}
35+
* @param {string} text The text containing a var() function.
36+
* @returns {{ name: string, fallbackText: string | null } | null} The parsed variable name and optional fallback, or null if not a var().
3737
*/
3838
function parseVarFunction(text) {
3939
const match = text.match(varFunctionPattern);
@@ -50,7 +50,7 @@ function parseVarFunction(text) {
5050
* Extracts the list of fallback value or variable name used in a `var()` that is used as fallback function.
5151
* For example, for `var(--my-color, var(--fallback-color, red));` it will return `["--fallback-color", "red"]`.
5252
* @param {string} value The fallback value that is used in `var()`.
53-
* @return {Array<string>} The list of variable names of fallback value.
53+
* @returns {Array<string>} The list of variable names of fallback value.
5454
*/
5555
function getVarFallbackList(value) {
5656
const list = [];
@@ -220,10 +220,10 @@ export default {
220220
/**
221221
* Resolves a fallback text which can contain nested var() calls.
222222
* Returns the first resolvable value or null if none resolve.
223-
* @param {string} rawFallbackText
224-
* @param {Map<string, string>} cache Cache for memoization within a single resolution scope
225-
* @param {Set<string>} [seen] Set of already seen variables to detect cycles
226-
* @returns {string | null}
223+
* @param {string} rawFallbackText The raw fallback text to resolve.
224+
* @param {Map<string, string>} cache Cache for memoization within a single resolution scope.
225+
* @param {Set<string>} [seen] Set of already seen variables to detect cycles.
226+
* @returns {string | null} The resolved fallback value, or null if none can be resolved.
227227
*/
228228
function resolveFallback(rawFallbackText, cache, seen = new Set()) {
229229
const fallbackVarList = getVarFallbackList(rawFallbackText);

src/rules/use-baseline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ export default {
589589
* Checks a property value function to see if it's a baseline feature.
590590
* @param {FunctionNodePlain} child The node to check.
591591
* @returns {void}
592-
**/
592+
*/
593593
function checkPropertyValueFunction(child) {
594594
if (allowFunctions.has(child.name)) {
595595
return;

0 commit comments

Comments
 (0)