Skip to content

Bug: Empty CSS file causes TypeError: Error while loading rule 'css/font-family-fallbacks': Cannot read properties of undefined (reading 'cssWideKeywords') #478

Description

@nwcm

Environment

ESLint version: ESLint: 9.39.4
@eslint/css version: @eslint/css@npm:1.3.0
Node version: v24.16.0
npm version: 11.13.0
Operating System: Windows 11

Which language are you using?

stylesheet

What did you do?

Configuration empty css file causes exception

import css from "@eslint/css";

import { defineConfig } from "eslint/config";

export default defineConfig([

  {
    files: ["src/**/*.css"],
    plugins: { css },
    extends: ["css/recommended"]
  }
]);

{}

What did you expect to happen?

yarn eslint

What actually happened?

Oops! Something went wrong! :(

ESLint: 9.39.4

TypeError: Error while loading rule 'css/font-family-fallbacks': Cannot read properties of undefined (reading 'cssWideKeywords')
Occurred while linting C:\Users\somePath\src\someComponent\component.css
    at Object.create (file:///C:/Users/somePath/node_modules/@eslint/css/dist/rules/font-family-fallbacks.js:111:58)
    at createRuleListeners (C:\Users\somePath\node_modules\eslint\lib\linter\linter.js:1019:15)
    at C:\Users\somePath\node_modules\eslint\lib\linter\linter.js:1151:7
    at Array.forEach (<anonymous>)
    at runRules (C:\Users\somePath\node_modules\eslint\lib\linter\linter.js:1085:31)
    at #flatVerifyWithoutProcessors (C:\Users\somePath\node_modules\eslint\lib\linter\linter.js:2115:4)
    at Linter._verifyWithFlatConfigArrayAndWithoutProcessors (C:\Users\somePath\node_modules\eslint\lib\linter\linter.js:2203:43)
    at Linter._verifyWithFlatConfigArray (C:\Users\some\node_modules\eslint\lib\linter\linter.js:2306:15)
    at Linter.verify (C:\Users\somePath\node_modules\eslint\lib\linter\linter.js:1677:10)
    at Linter.verifyAndFix (C:\Users\somePath\node_modules\eslint\lib\linter\linter.js:2571:20)
    at verifyText (C:\Users\somePath\node_modules\eslint\lib\eslint\eslint-helpers.js:1180:45)
    at readAndVerifyFile (C:\Users\somePath\node_modules\eslint\lib\eslint\eslint-helpers.js:1321:10)```

### Link to Minimal Reproducible Example

https://domain

### Participation

- [x] I am willing to submit a pull request for this issue.

### AI acknowledgment

- [x] I did not use AI to generate this issue report.
- [ ] (If the above is not checked) I have reviewed the AI-generated content before submitting.

### Additional comments

_No response_

Metadata

Metadata

Assignees

Labels

acceptedThere is consensus among the team that this change meets the criteria for inclusionbugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Ready to Implement

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions