Skip to content

Commit

Permalink
Merge pull request #720 from frog-pond/hawken/tsc-on-js
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkrives authored May 25, 2024
2 parents 49832b9 + 76385d1 commit a888496
Show file tree
Hide file tree
Showing 105 changed files with 6,534 additions and 2,239 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ on:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node-version: [ 22.x ]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build

test:
runs-on: ubuntu-latest
strategy:
Expand All @@ -24,6 +40,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npm test

smoke-test-stolaf:
Expand All @@ -40,6 +57,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npm run test-stolaf-college

smoke-test-carleton:
Expand All @@ -56,6 +74,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npm run test-carleton-college

lint:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@
# Logs
*.log
npm-debug.log*

# Typescript
/.tsbuildinfo
/dist/
32 changes: 24 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
FROM node:22-alpine
FROM node:22-alpine AS modules_dev
WORKDIR /app

RUN apk add -U curl
COPY --link ./package.json ./package-lock.json ./
RUN npm ci

WORKDIR /app
COPY ./package.json ./package-lock.json ./

FROM modules_dev AS modules
RUN npm ci --omit=dev

HEALTHCHECK --interval=20s --timeout=1s \
CMD curl -f http://localhost:80/ping

COPY ./source ./source
FROM modules_dev AS build
COPY --link tsconfig.json .
COPY --link ./source ./source
COPY --link ./types ./types
RUN npm run build


FROM node:22-alpine AS runtime
WORKDIR /app

RUN apk add -U curl

COPY --link ./package.json ./package-lock.json ./
COPY --link --from=modules /app/node_modules ./node_modules
COPY --link --from=build /app/dist ./dist

ENV NODE_ENV=production
ENV NODE_PORT=80
ENV INSTITUTION=unknown

CMD node -r dotenv/config ./source/ccc-server/index.js
HEALTHCHECK --interval=20s --timeout=1s \
CMD curl -f http://localhost:80/ping

CMD node ./dist/source/ccc-server/index.js
27 changes: 21 additions & 6 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,29 @@ import js from '@eslint/js'
import globals from 'globals'

import prettier from 'eslint-config-prettier'
import ts from 'typescript-eslint'

/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */
export default [
js.configs.recommended,
...ts.configs.strictTypeChecked,
...ts.configs.stylisticTypeChecked,
prettier,
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {...globals.node},
parserOptions: {
project: true,
tsconfigRoot: import.meta.dirname,
},
},
rules: {
'array-callback-return': 'error',
camelcase: ['warn', {properties: 'never', ignoreDestructuring: true}],
'consistent-this': ['error', 'self'],
curly: ['warn', 'multi-line'],
'default-case': 'error',
'guard-for-in': 'error',
eqeqeq: ['error', 'always', {null: 'ignore'}],
'linebreak-style': ['error', 'unix'],
Expand All @@ -29,10 +36,7 @@ export default [
'no-div-regex': 'error',
'no-eq-null': 'warn',
'no-extra-label': 'error',
'no-implicit-coercion': [
'error',
{boolean: true, number: true, string: true},
],
'no-implicit-coercion': ['error', {boolean: true, number: true, string: true}],
'no-implicit-globals': 'error',
'no-multi-assign': 'error',
'no-new-symbol': 'error',
Expand All @@ -42,14 +46,25 @@ export default [
'no-undef-init': 'off',
'no-underscore-dangle': 'off',
'no-unmodified-loop-condition': 'error',
'no-unused-vars': ['warn', {args: 'after-used', argsIgnorePattern: '^_'}],
'@typescript-eslint/no-unused-vars': ['warn', {args: 'after-used', argsIgnorePattern: '^_'}],
'no-useless-constructor': 'error',
'no-var': 'error',
'prefer-const': 'off',
'prefer-promise-reject-errors': 'error',
'prefer-spread': 'error',
quotes: ['warn', 'single', 'avoid-escape'],
'require-await': 'warn',
semi: 'off',

// conflicts with the noPropertyAccessFromIndexSignature tsconfig rule
'@typescript-eslint/dot-notation': ['error', {allowIndexSignaturePropertyAccess: true}],
},
},
{
files: ['**/*.js'],
...ts.configs.disableTypeChecked,
},
{
ignores: ['dist/*'],
},
]
Loading

0 comments on commit a888496

Please sign in to comment.