Skip to content

Commit

Permalink
Adjust error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Nov 20, 2024
1 parent 7128750 commit be6189a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

<!-- Rule Table End -->

Expand Down
19 changes: 8 additions & 11 deletions src/rules/no-invalid-at-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//-----------------------------------------------------------------------------

import { lexer } from "css-tree";
import { isSyntaxReferenceError, isSyntaxMatchError } from "../util.js";
import { isSyntaxMatchError } from "../util.js";

//-----------------------------------------------------------------------------
// Helpers
Expand All @@ -28,6 +28,8 @@ function extractMetaDataFromError(error) {
messageId = message.includes("should not")
? "invalidExtraPrelude"
: "missingPrelude";
} else if (message.includes("descriptor")) {
messageId = "invalidDescriptor";
}

return {
Expand Down Expand Up @@ -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: {
Expand All @@ -151,7 +144,11 @@ export default {
column: loc.start.column + node.property.length,
},
},
...metaData,
messageId: "unknownDescriptor",
data: {
name: atRule.name,
descriptor: node.property,
},
});
}
},
Expand Down

0 comments on commit be6189a

Please sign in to comment.