diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..f89e0ef5 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,18 @@ +name: Code style checks + +on: pull_request + +jobs: + javascript: + name: JavaScript + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Run linter + run: npm run lint:js diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml deleted file mode 100644 index 25007486..00000000 --- a/.github/workflows/pull-request.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Pull request - -on: - pull_request: - branches: - - master - push: - branches: - - master - -jobs: - build: - name: Pull request - runs-on: ubuntu-latest - if: github.repository == 'nhsuk/nhsuk-prototype-kit' - - steps: - - uses: actions/checkout@v4 - - - name: Install dependencies - run: npm install - - - name: Run linting - run: npm run lint:js diff --git a/app.js b/app.js index a22dbd63..92ab106c 100755 --- a/app.js +++ b/app.js @@ -23,7 +23,7 @@ const routes = require('./app/routes'); const utils = require('./lib/utils'); // Set configuration variables -const port = parseInt(process.env.PORT) || config.port; +const port = parseInt(process.env.PORT, 10) || config.port; // Initialise applications const app = express(); @@ -53,7 +53,7 @@ const nunjucksConfig = { nunjucksConfig.express = app; -let nunjucksAppEnv = nunjucks.configure(appViews, nunjucksConfig); +const nunjucksAppEnv = nunjucks.configure(appViews, nunjucksConfig); nunjucksAppEnv.addGlobal('version', packageInfo.version); // Add Nunjucks filters diff --git a/app/config.js b/app/config.js index 537c2514..36fa24a2 100644 --- a/app/config.js +++ b/app/config.js @@ -10,4 +10,4 @@ module.exports = { // Automatically stores form data, and send to all views useAutoStoreData: 'true', -} +}; diff --git a/app/routes.js b/app/routes.js index 9d8e3248..ee6db16d 100644 --- a/app/routes.js +++ b/app/routes.js @@ -15,15 +15,12 @@ router.post('/install', (req, res) => { if (install === 'Simple') { res.redirect('/install/simple'); - } - else if (install === 'Developer') { + } else if (install === 'Developer') { res.redirect('/install/advanced'); - } - else if (install === 'Download') { + } else if (install === 'Download') { res.redirect('/install/download-zip'); - } - else { - res.redirect('/install') + } else { + res.redirect('/install'); } }); @@ -33,11 +30,9 @@ router.post('/install/mac', (req, res) => { if (machine === 'Mac') { res.redirect('/install/mac/terminal'); - } - else if (machine === 'Windows') { + } else if (machine === 'Windows') { res.redirect('/install/windows/terminal'); - } - else res.redirect('/install/mac-or-windows') + } else res.redirect('/install/mac-or-windows'); }); router.get('/download', (req, res) => { diff --git a/package.json b/package.json index ba07ef60..497eb1e7 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "test": "jest --coverage=true", "prewatch": "gulp build", "watch": "gulp", - "lint:js": "eslint -c ./linters/.eslintrc.js app.js middleware/**/*.js lib/**/*.js app/*.js docs/*.js" + "lint:js": "eslint -c ./linters/.eslintrc.js app.js middleware/**/*.js lib/**/*.js app/*.js" }, "author": "https://github.com/nhsuk/", "license": "MIT",