Skip to content

Commit 0acbfd1

Browse files
authored
Allow JSX spread attributes in style attribute checks (#62)
1 parent f7b9173 commit 0acbfd1

File tree

5 files changed

+7
-2
lines changed

5 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- [#56](https://github.com/green-code-initiative/creedengo-javascript/issues/56) **BREAKING:** Rename plugin to creedengo-javascript
1919
- [#44](https://github.com/green-code-initiative/creedengo-javascript/pull/44) Implement the rule GCI523 for React Native
2020
- [#52](https://github.com/green-code-initiative/creedengo-javascript/pull/52) Remove trailing dots in Sonar rules descriptions
21+
- [#62](https://github.com/green-code-initiative/creedengo-javascript/pull/62) Fix style attribute checks in GCI26 and GCI29
2122
- Update Docker Compose configuration file to V2
2223

2324
### Deleted

eslint-plugin/lib/rules/avoid-css-animations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = {
3737
return {
3838
JSXOpeningElement(node) {
3939
const styleAttribute = node.attributes.find(
40-
(attribute) => attribute.name.name === "style",
40+
(attribute) => attribute.name?.name === "style",
4141
);
4242

4343
if (styleAttribute?.value.expression) {

eslint-plugin/lib/rules/prefer-shorthand-css-notations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ module.exports = {
8484
return {
8585
JSXOpeningElement(node) {
8686
const styleAttribute = node.attributes.find(
87-
(attr) => attr.name.name === "style",
87+
(attr) => attr.name?.name === "style",
8888
);
8989
if (styleAttribute) {
9090
const nodePropertyNames =

eslint-plugin/tests/lib/rules/avoid-css-animations.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ ruleTester.run("avoid-css-animations", rule, {
5353
`,
5454
`<div style={{ width: '100px', height: '100px' }}>Hello world</div>`,
5555
`<div style="border: 2px solid red">My red element</div>`,
56+
// spread attributes should not throw an error (#49)
57+
"<input {...inputProps} className={styles.input} onChange={handleChange}/>",
5658
],
5759

5860
invalid: [

eslint-plugin/tests/lib/rules/prefer-shorthand-css-notations.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ ruleTester.run("prefer-shorthand-css-notations", rule, {
7373
code: "<div style={{ animationName: 'example', animationDuration: '5s' }}/>",
7474
options: [{ disableProperties: ["animation"] }],
7575
},
76+
// spread attributes should not throw an error (#49)
77+
"<input {...inputProps} className={styles.input} onChange={handleChange}/>",
7678
],
7779
invalid: [
7880
{

0 commit comments

Comments
 (0)