Skip to content

Commit

Permalink
chore: repository housekeeping (#1237)
Browse files Browse the repository at this point in the history
1. Add an `npm run check` command that runs all of the commonly failing checks: eslint, tsc, prettier and audit.

2. Run `check` as part of the CI build

3. Ensure linter and prettier run on the pre-commit hook

4. Fix the linter and formatting errors that had crept in while these checks were not enforced
  • Loading branch information
tackley authored Sep 12, 2023
1 parent 04456c0 commit 19ef0e0
Show file tree
Hide file tree
Showing 15 changed files with 1,881 additions and 554 deletions.
3 changes: 2 additions & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ runs:
cache: npm
- run: npm ci
shell: bash
- run: npm audit
# check includes audit, tsc, lint, prettier
- run: npm run check
shell: bash
- run: npm test
shell: bash
Expand Down
58 changes: 29 additions & 29 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ name: "CodeQL"

on:
push:
branches: [ main, dev, prod ]
branches: [main, dev, prod]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
branches: [main]
schedule:
- cron: '35 22 * * 2'
- cron: "35 22 * * 2"

jobs:
analyze:
Expand All @@ -32,39 +32,39 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
language: ["javascript"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
3 changes: 1 addition & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx pretty-quick --staged
npm run lint
npx lint-staged
8 changes: 7 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# general directories to ignore
html/
node_modules/
src/js
src/js
tsbuild/

# let npm maintain the formatting of its files
package-lock.json
package.json
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Currently the page uses a html template [`index.html`](./src/index.html) styled

By convention, the javsascript this interacts with elements in the html template by id and the css relies solely on class names.

Before you commit, you most likely want to ensure the continuous integration build will not
fail. To run the most likely-to-fail checks, use:

$ npm run check

To build for production:

$ npm ci
Expand Down
6 changes: 5 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
/** @type {import('jest').Config} */
const config = {
preset: "ts-jest",
testEnvironment: "jsdom",
rootDir: "src",
};

module.exports = config;
Loading

0 comments on commit 19ef0e0

Please sign in to comment.