Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ESLint to the project and solving the ESLint Errors #296

Closed
wants to merge 13 commits into from
15 changes: 15 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package.json
package-lock.json
node_modules/
.DS_Store
*.html
.gitignore
.prettierignore
.prettierrc
AUTHORS
CHECKS
docker-compose.yml
Dockerfile
LICENSE
# nightwatch.conf.js
README.md
30 changes: 30 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es2021: true,
node: true,
},
extends: "eslint:recommended",
overrides: [
{
env: {
node: true,
},
files: [".eslintrc.{js,cjs}"],
parserOptions: {
sourceType: "script",
},
},
],
parserOptions: {
ecmaVersion: "latest",
},
globals: {
Tools: true,
},
rules: {
"no-prototype-builtins": "off",
"no-undef": "warn",
},
};
15 changes: 14 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,23 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install dependencies
run: npm install

- name: Run Prettier check
run: npx prettier --check .

lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install dependencies
run: npm install

- name: Run ESLint
run: npx eslint .
6 changes: 5 additions & 1 deletion client-data/js/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @licend
*/

const Minitpl = require("./minitpl");
var Tools = {};

Tools.i18n = (function i18n() {
Expand Down Expand Up @@ -75,6 +75,7 @@ Tools.connect = function () {
socket_params.query = "token=" + params.get("token");
}

// eslint-disable-next-line no-undef
this.socket = io.connect("", socket_params);

//Receive draw instructions from the server
Expand Down Expand Up @@ -588,6 +589,7 @@ Tools.toolHooks = [
};
}

// eslint-disable-next-line no-unused-vars
function wrapUnsetHover(f, toolName) {
return function unsetHover(evt) {
document.activeElement &&
Expand Down Expand Up @@ -643,6 +645,7 @@ Tools.generateUID = function (prefix, suffix) {
Tools.createSVGElement = function createSVGElement(name, attrs) {
var elem = document.createElementNS(Tools.svg.namespaceURI, name);
if (typeof attrs !== "object") return elem;
// eslint-disable-next-line no-unused-vars
Object.keys(attrs).forEach(function (key, i) {
elem.setAttributeNS(null, key, attrs[key]);
});
Expand Down Expand Up @@ -764,6 +767,7 @@ Tools.svg.height.baseVal.value = document.body.clientHeight;
var dy = evt.clientY - pos.scroll;
menu.scrollTop = pos.top - dy;
}
// eslint-disable-next-line no-unused-vars
function menu_mouseup(evt) {
menu.removeEventListener("mousemove", menu_mousemove);
document.removeEventListener("mouseup", menu_mouseup);
Expand Down
1 change: 1 addition & 0 deletions client-data/js/canvascolor.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
// @use_types_for_optimization true
// ==/ClosureCompiler==

// eslint-disable-next-line no-unused-vars
var canvascolor = (function () {
//Code Isolation
"use strict";
Expand Down
5 changes: 3 additions & 2 deletions client-data/js/minitpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
*
* @licend
*/

Minitpl = (function () {
// eslint-disable-next-line no-unused-vars
const Minitpl = (function () {
// eslint-disable-next-line no-unused-vars
function Minitpl(elem, data) {
this.elem = typeof elem === "string" ? document.querySelector(elem) : elem;
if (!elem) {
Expand Down
Loading
Loading