From 9ea9efa6b8150a651fb00d174c74ae7aa0581a47 Mon Sep 17 00:00:00 2001 From: utarwyn Date: Mon, 18 Sep 2023 20:52:23 +0200 Subject: [PATCH] Move all Javascript rules --- .../src/main/rules/EC11/EC11.json | 4 +- .../main/rules/EC11/javascript/EC11.asciidoc | 17 +++++---- .../src/main/rules/EC12/EC12.json | 4 +- .../main/rules/EC12/javascript/EC12.asciidoc | 14 +++---- .../src/main/rules/EC13/EC13.json | 6 +-- .../main/rules/EC13/javascript/EC13.asciidoc | 14 +++---- .../EC24/{js => javascript}/EC24.asciidoc | 0 .../EC25/{js => javascript}/EC25.asciidoc | 0 .../EC26/{js => javascript}/EC26.asciidoc | 0 .../EC29/{js => javascript}/EC29.asciidoc | 0 .../EC30/{js => javascript}/EC30.asciidoc | 0 .../src/main/rules/EC8/EC8.json | 4 +- .../main/rules/EC8/javascript/EC8.asciidoc | 19 +++++----- .../src/main/rules/EC9/EC9.json | 4 +- .../main/rules/EC9/javascript/EC9.asciidoc | 38 +++++-------------- 15 files changed, 54 insertions(+), 70 deletions(-) rename ecocode-rules-specifications/src/main/rules/EC24/{js => javascript}/EC24.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC25/{js => javascript}/EC25.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC26/{js => javascript}/EC26.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC29/{js => javascript}/EC29.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC30/{js => javascript}/EC30.asciidoc (100%) diff --git a/ecocode-rules-specifications/src/main/rules/EC11/EC11.json b/ecocode-rules-specifications/src/main/rules/EC11/EC11.json index 878a34665..1e878d469 100644 --- a/ecocode-rules-specifications/src/main/rules/EC11/EC11.json +++ b/ecocode-rules-specifications/src/main/rules/EC11/EC11.json @@ -7,9 +7,9 @@ "constantCost": "5min" }, "tags": [ + "ecocode", "eco-design", - "performance", - "ecocode" + "performance" ], "defaultSeverity": "Major", "compatibleLanguages": [ diff --git a/ecocode-rules-specifications/src/main/rules/EC11/javascript/EC11.asciidoc b/ecocode-rules-specifications/src/main/rules/EC11/javascript/EC11.asciidoc index b5a2a8649..a932fa16c 100644 --- a/ecocode-rules-specifications/src/main/rules/EC11/javascript/EC11.asciidoc +++ b/ecocode-rules-specifications/src/main/rules/EC11/javascript/EC11.asciidoc @@ -1,20 +1,21 @@ -## Rule details +This rule aims to reduce DOM access assigning its object to variable when access multiple time. +It saves CPU cycles. -This rule aims to reduce DOM access assigning its object to variable when access multiple time. It saves CPU cycles. - -## Examples +== Examples Examples of **incorrect** code for this rule: -```js +[source,js] +---- var el1 = document.getElementById("block1").test1; var el2 = document.getElementById("block1").test2; -``` +---- Examples of **correct** code for this rule: -```js +[source,js] +---- var blockElement = document.getElementById("block1"); var el1 = blockElement.test1; var el2 = blockElement.test2; -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC12/EC12.json b/ecocode-rules-specifications/src/main/rules/EC12/EC12.json index 67c6010cf..06c452765 100644 --- a/ecocode-rules-specifications/src/main/rules/EC12/EC12.json +++ b/ecocode-rules-specifications/src/main/rules/EC12/EC12.json @@ -7,9 +7,9 @@ "constantCost": "10min" }, "tags": [ + "ecocode", "eco-design", - "performance", - "ecocode" + "performance" ], "defaultSeverity": "Major", "compatibleLanguages": [ diff --git a/ecocode-rules-specifications/src/main/rules/EC12/javascript/EC12.asciidoc b/ecocode-rules-specifications/src/main/rules/EC12/javascript/EC12.asciidoc index 5bd836997..7793d7389 100644 --- a/ecocode-rules-specifications/src/main/rules/EC12/javascript/EC12.asciidoc +++ b/ecocode-rules-specifications/src/main/rules/EC12/javascript/EC12.asciidoc @@ -1,24 +1,24 @@ -## Rule Details - This rule aims to disallow batching multiple style changes at once. To limit the number of repaint/reflow, it is advised to batch style modifications by adding a class containing all style changes that will generate a unique reflow. -## Examples +== Examples Examples of **non-compliant** code for this rule: -```html +[source,html] +---- -``` +---- Examples of **compliant** code for this rule: -```html +[source,html] +----