From be6189ae0fbbf79ba299823b2ed9a4d46f36af04 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 20 Nov 2024 14:17:34 -0500 Subject: [PATCH] Adjust error reporting --- README.md | 2 +- src/rules/no-invalid-at-rules.js | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 80bca80..c931e62 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,8 @@ export default [ | :--------------------------------------------------------------- | :-------------------------------- | :-------------: | | [`no-duplicate-imports`](./docs/rules/no-duplicate-imports.md) | Disallow duplicate @import rules. | yes | | [`no-empty-blocks`](./docs/rules/no-empty-blocks.md) | Disallow empty blocks. | yes | -| [`no-invalid-properties`](./docs/rules/no-invalid-properties.md) | Disallow invalid properties. | yes | | [`no-invalid-at-rules`](./docs/rules/no-invalid-at-rules.md) | Disallow invalid at-rules. | yes | +| [`no-invalid-properties`](./docs/rules/no-invalid-properties.md) | Disallow invalid properties. | yes | diff --git a/src/rules/no-invalid-at-rules.js b/src/rules/no-invalid-at-rules.js index 17f099c..c42b8a0 100644 --- a/src/rules/no-invalid-at-rules.js +++ b/src/rules/no-invalid-at-rules.js @@ -8,7 +8,7 @@ //----------------------------------------------------------------------------- import { lexer } from "css-tree"; -import { isSyntaxReferenceError, isSyntaxMatchError } from "../util.js"; +import { isSyntaxMatchError } from "../util.js"; //----------------------------------------------------------------------------- // Helpers @@ -28,6 +28,8 @@ function extractMetaDataFromError(error) { messageId = message.includes("should not") ? "invalidExtraPrelude" : "missingPrelude"; + } else if (message.includes("descriptor")) { + messageId = "invalidDescriptor"; } return { @@ -133,15 +135,6 @@ export default { } const loc = node.loc; - const metaData = isSyntaxReferenceError(error) - ? { - messageId: "unknownDescriptor", - data: { - name: atRule.name, - descriptor: error.reference, - }, - } - : extractMetaDataFromError(error); context.report({ loc: { @@ -151,7 +144,11 @@ export default { column: loc.start.column + node.property.length, }, }, - ...metaData, + messageId: "unknownDescriptor", + data: { + name: atRule.name, + descriptor: node.property, + }, }); } },