Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#46](https://github.com/green-code-initiative/creedengo-javascript/pull/46) Add rule `@creedengo/prefer-lighter-formats-for-image-files` (GCI31)
- [#68](https://github.com/green-code-initiative/creedengo-javascript/pull/68) Add support for SonarQube up to 25.3

### Fixed

- [#69](https://github.com/green-code-initiative/creedengo-javascript/pull/69) Only support string literals in GCI11

## [2.0.0] - 2025-01-22

### Added
Expand Down
4 changes: 3 additions & 1 deletion eslint-plugin/lib/rules/no-multiple-access-dom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ module.exports = {
CallExpression(node) {
if (
node.callee.object?.name === "document" &&
DOMAccessMethods.includes(node.callee.property.name)
DOMAccessMethods.includes(node.callee.property.name) &&
// We only accept string literals as arguments for now
node.arguments[0].type === "Literal"
) {
const selectorValue = node.arguments[0].value;
const uniqueCallStr = node.callee.property.name + selectorValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ ruleTester.run("no-multiple-access-dom-element", rule, {
function test() { var link = document.getElementsByTagName('a'); }
var link = document.getElementsByTagName('a');
`,
`
for (var i = 0; i < 10; i++) {
var test = document.getElementsByName("test" + i)[0].value;
var test2 = document.getElementsByName("test2" + i)[0].value;
}
`,
],

invalid: [
Expand Down