Skip to content
Merged
3 changes: 3 additions & 0 deletions packages/eslint-plugin/changelogs/upcoming/9368.md
Comment thread
weronikaolejniczak marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Bug fixes**

- Fixed `no-css-color` ESLint rule crash when analyzing functions that return `undefined` or non-object values
16 changes: 13 additions & 3 deletions packages/eslint-plugin/src/rules/no_css_color.ts
Comment thread
weronikaolejniczak marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,20 @@ export const NoCssColor = ESLintUtils.RuleCreator.withoutDocs({
return;
}

const returnArgument = (
functionReturnStatementNode as TSESTree.ReturnStatement
).argument;

if (
!returnArgument ||
returnArgument.type !== 'ObjectExpression'
) {
return;
}

declarationPropertiesNode = (
(functionReturnStatementNode as TSESTree.ReturnStatement)
.argument as TSESTree.ObjectExpression
)?.properties.filter(
returnArgument as TSESTree.ObjectExpression
).properties.filter(
(property): property is TSESTree.Property =>
property.type === 'Property'
);
Expand Down
4 changes: 3 additions & 1 deletion packages/eui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
'plugin:deprecation/recommended',
'plugin:storybook/recommended',
'plugin:@elastic/eui/recommended',
// Prettier options need to come last, in order to override other style rules
'plugin:prettier/recommended',
],
Expand All @@ -48,7 +49,8 @@ module.exports = {
'react',
'react-hooks',
'@emotion',
'deprecation'
'deprecation',
'@elastic/eui'
],
rules: {
'deprecation/deprecation': 'warn',
Expand Down
1 change: 1 addition & 0 deletions packages/eui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"@cypress/webpack-dev-server": "^1.7.0",
"@elastic/charts": "^64.1.0",
"@elastic/datemath": "^5.0.3",
"@elastic/eslint-plugin-eui": "workspace:*",
"@elastic/eui-theme-borealis": "workspace:*",
"@emotion/babel-preset-css-prop": "^11.11.0",
"@emotion/cache": "^11.11.0",
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7062,7 +7062,7 @@ __metadata:
languageName: node
linkType: hard

"@elastic/eslint-plugin-eui@workspace:packages/eslint-plugin":
"@elastic/eslint-plugin-eui@workspace:*, @elastic/eslint-plugin-eui@workspace:packages/eslint-plugin":
version: 0.0.0-use.local
resolution: "@elastic/eslint-plugin-eui@workspace:packages/eslint-plugin"
dependencies:
Expand Down Expand Up @@ -7345,6 +7345,7 @@ __metadata:
"@cypress/webpack-dev-server": "npm:^1.7.0"
"@elastic/charts": "npm:^64.1.0"
"@elastic/datemath": "npm:^5.0.3"
"@elastic/eslint-plugin-eui": "workspace:*"
"@elastic/eui-theme-borealis": "workspace:*"
"@elastic/eui-theme-common": "workspace:*"
"@elastic/prismjs-esql": "npm:^1.1.2"
Expand Down