diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..3b8b9c3 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,6 @@ +node_modules +package-lock.json +dist +cba.zip +tests +jquery-1.7.2.min.js \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..c3e3ffb --- /dev/null +++ b/.eslintrc @@ -0,0 +1,22 @@ +{ + "env": { + "browser": true, + "node": true, + "es2021": true + }, + "extends": "eslint:recommended", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "rules": { + "global-require": "off", + "no-cond-assign": "off", + "no-empty": "off" + }, + "globals": { + "cba": true, + "browser": true, + "chrome": true + } +} diff --git a/.github/workflows/running-tests.yml b/.github/workflows/running-tests.yml index 692c593..99ee076 100644 --- a/.github/workflows/running-tests.yml +++ b/.github/workflows/running-tests.yml @@ -14,6 +14,9 @@ jobs: - name: Prepare dependencies run: sudo apt-get install xvfb && npm install - + + - name: Run linters + run: npm run lint + - name: Run tests run: xvfb-run npm test diff --git a/README.md b/README.md index 37c21c6..cb02597 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ be loaded in the chrome unless actual extension is reloaded in the ```bash npm test # Run puppeteer test npm run test:pages # Starts server with test page used by puppeteer +npm run lint # Run linter ``` ## Publishing diff --git a/package.json b/package.json index 2922fe5..171da4c 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "test": "npm run build:webpack && (http-server tests/pages -s -p 3001 & mocha tests/mocha.js)", "test:pages": "http-server tests/pages -s -p 3000", + "lint": "eslint .", "posttest": "kill $(lsof -t -i:3001)", "import:components": "cba-components --single-bundle --prod --output dist", "build": "npm run clean && npm run build:webpack:prod && cd dist/;zip -r ../cba.zip .;cd ..", @@ -33,6 +34,8 @@ "webpack": "^5.89.0" }, "devDependencies": { + "eslint": "^8.56.0", + "eslint-plugin-jsdoc": "^46.9.1", "http-server": "^14.1.1", "mocha": "^10.2.0", "webpack-cli": "^5.1.4" diff --git a/src/js/background/actions.js b/src/js/background/actions.js index d2abe22..fb4496e 100644 --- a/src/js/background/actions.js +++ b/src/js/background/actions.js @@ -73,7 +73,9 @@ async function actionExecution(instruction) break; } case "bg-inject": { + // eslint-disable-next-line no-unused-vars let sendInstruction = () => ""; + // eslint-disable-next-line no-unused-vars const actionToPlay = (actionInd) => cba.instructArray = cba.defInstructArray.slice(actionInd); let sendBgInstruction = true; const clipboard = cba.clipboard; @@ -125,6 +127,7 @@ async function bgFunctionParser(value) { return false; const functionName = method[1]; + let attribute; while (attribute = attributePattern.exec(value)) { const clipboard = clipboardPattern.exec(attribute[1]); if (clipboard) diff --git a/src/js/cs/actions.js b/src/js/cs/actions.js index 0bb7c9e..3f2c464 100644 --- a/src/js/cs/actions.js +++ b/src/js/cs/actions.js @@ -19,7 +19,7 @@ let clipboard = {}; -browser.runtime.onMessage.addListener((request, sender) => { +browser.runtime.onMessage.addListener((request) => { if(request.action == "executeAction") { clipboard = request.clipboard; try { diff --git a/src/js/cs/main.js b/src/js/cs/main.js index 5413f2a..2c24295 100644 --- a/src/js/cs/main.js +++ b/src/js/cs/main.js @@ -21,7 +21,7 @@ require("./record"); require("./actions"); -browser.runtime.onMessage.addListener((request, sender) => { +browser.runtime.onMessage.addListener((request) => { if(request.action == "highlight") { return setHighlight(request.selector); } diff --git a/src/js/popup.js b/src/js/popup.js index d038ade..7a9a9a9 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -22,7 +22,7 @@ require("./ui/projects"); function trackButtonClick(e) { _gaq.push(['_trackEvent', e.target.id, 'clicked']); -}; +} function analytAllButtons() { var buttons = document.querySelectorAll('cba-button'); diff --git a/src/js/ui/notification.js b/src/js/ui/notification.js index b35fc48..730c67c 100644 --- a/src/js/ui/notification.js +++ b/src/js/ui/notification.js @@ -55,5 +55,5 @@ class Notification { module.exports = {Notification, NO_PROJ_SELECTED, NO_PROJ_GROUP_SELECTED, NO_ACTION_SELECTED, SELECT_PROJ_NOT_GROUP, CHANGES_SAVED, NO_GROUP_ROOT_SELECTED, NO_IMPORT_DATA, NO_PROJ_GROUP_TYPE, PROJECT_IMPORTED, - NO_FUNCTION_NAME, NO_SELECTED_FUNCTION, CHANGES_SAVED, NAME_EXISTS_GROUP, + NO_FUNCTION_NAME, NO_SELECTED_FUNCTION, NAME_EXISTS_GROUP, NAME_EXISTS_PROJECT, PROJECT_EDIT};