Skip to content

Commit

Permalink
Run tests in CI, update eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
thaapasa committed Sep 28, 2024
1 parent cc3e5ba commit 7fc2841
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 14 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test Calculators

on: [workflow_dispatch, push]

jobs:
build:
name: Build and test calculators
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install deps
run: yarn install

- name: Lint
run: echo "Lint skipped - yarn lint"

- name: Run tests
run: yarn test
43 changes: 40 additions & 3 deletions .eslintrc.cjs → eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,43 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-undef */
import eslint from "@eslint/js";
import tseslint from 'typescript-eslint';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import reactHooks from "eslint-plugin-react-hooks";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import unusedImports from "eslint-plugin-unused-imports";

module.exports = {
export default tseslint.config({
files: ["src/**/*.ts", "src/**/*.tsx"],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
eslintPluginPrettierRecommended,
],
plugins: {
"react-hooks": reactHooks,
"simple-import-sort": simpleImportSort,
"unused-imports": unusedImports,
},
rules: {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
'no-console': 'warn',
'unused-imports/no-unused-imports': 'error',
'simple-import-sort/imports': ['warn'],
'simple-import-sort/exports': ['warn'],
}
})

/*
{
rules: {
"no-unused-vars": "warn",
"no-undef": "warn"
}
}
]
*/

/*
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
Expand Down Expand Up @@ -50,3 +86,4 @@ module.exports = {
},
},
};
*/
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
"scripts": {
"start": "vite",
"build": "vite build",
"test": "vitest",
"test": "vitest run",
"deploy": "sh script/deploy.sh",
"clean": "rm -rf dist/",
"eject": "react-scripts eject",
"lint": "bun lint-eslint && bun lint-tsc",
"lint": "yarn lint-eslint && yarn lint-tsc",
"lint-eslint": "eslint src",
"lint-tsc": "tsc --noEmit"
"lint-tsc": "tsc --noEmit",
"fix": "eslint --fix src"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -63,8 +64,6 @@
"@types/react-dom": "18.3.0",
"@types/uuid": "10.0.0",
"@types/xml2js": "0.4.14",
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0",
"@vitejs/plugin-react-swc": "^3.7.0",
"eslint": "^9.11.1",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -77,6 +76,7 @@
"prettier": "3.3.3",
"tslib": "2.7.0",
"typescript": "5.6.2",
"typescript-eslint": "^8.7.0",
"vite": "^5.4.8",
"vite-tsconfig-paths": "^5.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/TimePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export class TimePage extends React.Component<DateTimeProps, DateTimeState> {

constructor(props: DateTimeProps) {
super(props);
// eslint-disable-next-line

types.forEach(t => (this.state[t] = ''));
this.state.datePicker = undefined;
}
Expand Down
1 change: 0 additions & 1 deletion src/app/ui/component/ByteValueSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export class ByteValueSelector extends React.Component<SelectorProps, SelectorSt
super(props);

types.forEach(t => {
// eslint-disable-next-line
this.state[t] = typeInfo[t].write(this.props.setValue);
this.inputStr[t] = new Bacon.Bus<string | number>();
});
Expand Down
21 changes: 17 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/eslint-plugin@npm:^8.7.0":
"@typescript-eslint/eslint-plugin@npm:8.7.0":
version: 8.7.0
resolution: "@typescript-eslint/eslint-plugin@npm:8.7.0"
dependencies:
Expand All @@ -1325,7 +1325,7 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/parser@npm:^8.7.0":
"@typescript-eslint/parser@npm:8.7.0":
version: 8.7.0
resolution: "@typescript-eslint/parser@npm:8.7.0"
dependencies:
Expand Down Expand Up @@ -1971,8 +1971,6 @@ __metadata:
"@types/react-dom": "npm:18.3.0"
"@types/uuid": "npm:10.0.0"
"@types/xml2js": "npm:0.4.14"
"@typescript-eslint/eslint-plugin": "npm:^8.7.0"
"@typescript-eslint/parser": "npm:^8.7.0"
"@vitejs/plugin-react-swc": "npm:^3.7.0"
baconjs: "npm:3.0.19"
buffer: "npm:^6.0.3"
Expand Down Expand Up @@ -2003,6 +2001,7 @@ __metadata:
svg-rn: "npm:0.1.2"
tslib: "npm:2.7.0"
typescript: "npm:5.6.2"
typescript-eslint: "npm:^8.7.0"
uuid: "npm:10.0.0"
vite: "npm:^5.4.8"
vite-tsconfig-paths: "npm:^5.0.1"
Expand Down Expand Up @@ -5765,6 +5764,20 @@ __metadata:
languageName: node
linkType: hard

"typescript-eslint@npm:^8.7.0":
version: 8.7.0
resolution: "typescript-eslint@npm:8.7.0"
dependencies:
"@typescript-eslint/eslint-plugin": "npm:8.7.0"
"@typescript-eslint/parser": "npm:8.7.0"
"@typescript-eslint/utils": "npm:8.7.0"
peerDependenciesMeta:
typescript:
optional: true
checksum: 10c0/c0c3f909227c664f193d11a912851d6144a7cfcc0ac5e57f695c3e50679ef02bb491cc330ad9787e00170ce3be3a3b8c80bb81d5e20a40c1b3ee713ec3b0955a
languageName: node
linkType: hard

"typescript@npm:5.6.2":
version: 5.6.2
resolution: "typescript@npm:5.6.2"
Expand Down

0 comments on commit 7fc2841

Please sign in to comment.