summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2022-10-09 18:26:01 +0200
committerJulien Dessaux2022-10-09 18:26:01 +0200
commit2569c6332fb1f9b695b984f2a8f34eaee3f81d89 (patch)
tree8a0e0b6413de0d0a4441adddbf03c7ba661481ef
parentTweaked display (diff)
downloadjeux-de-mots-2569c6332fb1f9b695b984f2a8f34eaee3f81d89.tar.gz
jeux-de-mots-2569c6332fb1f9b695b984f2a8f34eaee3f81d89.tar.bz2
jeux-de-mots-2569c6332fb1f9b695b984f2a8f34eaee3f81d89.zip
Added eslint validation
-rw-r--r--.eslintrc.js36
-rw-r--r--GNUmakefile18
-rw-r--r--index.js18
3 files changed, 63 insertions, 9 deletions
diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 0000000..d1074ab
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,36 @@
+module.exports = {
+ "env": {
+ "browser": true,
+ "es2021": true
+ },
+ "extends": "eslint:recommended",
+ "overrides": [
+ {
+ "files": ["**/*.js"],
+ "globals": {
+ "CWDATA": "writable",
+ },
+ },
+ ],
+ "parserOptions": {
+ "ecmaVersion": "latest"
+ },
+ "rules": {
+ "indent": [
+ "error",
+ "tab"
+ ],
+ "linebreak-style": [
+ "error",
+ "unix"
+ ],
+ "quotes": [
+ "error",
+ "double"
+ ],
+ "semi": [
+ "error",
+ "always"
+ ]
+ }
+};
diff --git a/GNUmakefile b/GNUmakefile
new file mode 100644
index 0000000..bb10536
--- /dev/null
+++ b/GNUmakefile
@@ -0,0 +1,18 @@
+SHELL:=bash
+
+.PHONY: check
+check: ## make check # Check syntax of eventline jobs
+ eslint index.js
+
+.PHONY: init
+init: ## make init # initialize project dependencies
+ npm install eslint
+
+.PHONY: serve
+serve: ## make serve # run a python web server
+ python -m http.server 8000
+
+help:
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
+
+.DEFAULT_GOAL := help
diff --git a/index.js b/index.js
index a997839..ef244ae 100644
--- a/index.js
+++ b/index.js
@@ -1,4 +1,4 @@
-'use strict';
+"use strict";
var CW = function(){
// 0 point : blanches × 2.
@@ -30,7 +30,7 @@ var CW = function(){
"H", "H",
"V", "V",
"J", "Q", "K", "W", "X", "Y", "Z"
- ]
+ ];
const points = {
" ": 0,
E:1, A:1, I:1, N:1, O:1, R:1, S:1, T:1, U:1, L:1,
@@ -166,10 +166,10 @@ var CW = function(){
const line = CWDATA.board[y];
for(x=0; x<line.length; x++) {
letter = line[x];
- elt = document.getElementById(['s', y, '_', x].join(''));
+ elt = document.getElementById(["s", y, "_", x].join(""));
if (letter !== "") {
elt.className = "letter";
- elt.innerHTML = [letter, '<div class="points">', points[letter], "</div>"].join("");
+ elt.innerHTML = [letter, "<div class=\"points\">", points[letter], "</div>"].join("");
// we also remove the letter from the pool
idx = letters.findIndex(function(elt) { return elt === letter; });
if (idx != -1) {
@@ -210,9 +210,9 @@ var CW = function(){
prev = "JOKER";
}
if (y > 1) {
- letters_left = letters_left.concat(prev, 'x', y, ', ');
+ letters_left = letters_left.concat(prev, "x", y, ", ");
} else {
- letters_left = letters_left.concat(prev, ', ');
+ letters_left = letters_left.concat(prev, ", ");
}
prev = letter;
y = 1;
@@ -223,12 +223,12 @@ var CW = function(){
prev = "blanc";
}
if (y > 1) {
- letters_left = letters_left.concat(prev, 'x', y, '.');
+ letters_left = letters_left.concat(prev, "x", y, ".");
} else {
- letters_left = letters_left.concat(prev, '.');
+ letters_left = letters_left.concat(prev, ".");
}
}
- document.getElementById('letters_left').innerHTML = letters_left.join('');
+ document.getElementById("letters_left").innerHTML = letters_left.join("");
}
};
}();