Merge pull request #42 from cse110-fa22-group29/js-linting-ci

Implement JS linting framework and action
This commit is contained in:
look-its-ashton 2022-11-08 15:22:29 -08:00 committed by GitHub
commit d6e8291779
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 171 additions and 109 deletions

33
.eslintrc.json Normal file
View File

@ -0,0 +1,33 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": "eslint:recommended",
"overrides": [
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"indent": [
"error",
"tab"
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
],
"no-global-assign": 0
}
}

25
.github/workflows/js-linting.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: JS Linting
on:
pull_request:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
# Single deploy job since we're just deploying
test:
runs-on: ubuntu-latest
steps:
- name: Install apt updates
run: sudo apt -y update; sudo apt -y upgrade;
- name: Install prerequisites
run: sudo apt install -y nodejs npm;
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run: sudo npm install
- name: Run tests
run: sudo npm run lint

View File

@ -1,4 +1,4 @@
name: Jest JS Unit Test name: JS Unit Test
on: on:
pull_request: pull_request:

View File

@ -2,9 +2,12 @@
"name": "food-journal", "name": "food-journal",
"version": "1.0.0", "version": "1.0.0",
"scripts": { "scripts": {
"test": "mocha --recursive **/*.test.js" "test": "mocha --recursive **/*.test.js",
"lint": "eslint **/*.js",
"fix-style": "eslint --fix **/*.js"
}, },
"dependencies": { "devDependencies": {
"eslint": "^8.27.0",
"mocha": "10" "mocha": "10"
} }
} }

View File

@ -1,6 +1,7 @@
const {environment} = require("./testenv.js"); const {environment} = require("./testenv.js");
var assert = require('assert'); var assert = require("assert");
var {saveToLocal, getFromLocal, removeFromLocal, clearLocal} = require('./testenv_helpers'); var {describe, it, beforeEach} = require("mocha");
var {saveToLocal, getFromLocal, removeFromLocal, clearLocal} = require("./testenv_helpers");
beforeEach(() => { beforeEach(() => {
window = environment(); window = environment();