diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index cbf1e50..9463212 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -19,6 +19,7 @@ jobs: with: cache: 'npm' - run: npm ci + - run: npm lint - run: npm run build - run: npm test - uses: actions/upload-artifact@v3 diff --git a/egyptianNumber.ts b/egyptianNumber.ts index 14dc6c3..80c60a3 100644 --- a/egyptianNumber.ts +++ b/egyptianNumber.ts @@ -162,7 +162,7 @@ export class EgyptianNumber { static addAll(...summands: EgyptianNumber[]): EgyptianNumber { let result = new EgyptianNumber(0); - summands.forEach((summand, i, array) => { + summands.forEach((summand) => { result = this.add(result, summand); }) return result; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..5838c0f --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,15 @@ +import eslint from '@eslint/js'; +import tseslint from 'typescript-eslint'; + +export default tseslint.config( + eslint.configs.recommended, + ...tseslint.configs.recommended, + { + ignores: [ + 'bundle.mjs', + 'build/*', + 'docs/_build/*', + 'grammar/seshat/*', + ] + } +); \ No newline at end of file diff --git a/package.json b/package.json index e81341b..72f71dc 100644 --- a/package.json +++ b/package.json @@ -19,10 +19,14 @@ }, "scripts": { "antlr4ts": "antlr4ts", + "build": "npm run build-antlr && npm run build-bundle", "build-antlr": "antlr4ts ./grammar/seshat/SeshatLexer.g4 && antlr4ts ./grammar/seshat/SeshatParser.g4 -visitor -no-listener", "build-bundle": "node bundle.mjs", + "lint": "eslint .", + "run-dev-server": "node bundle.mjs --serve", + "test": "npm run test-js & npm run test-seshat", "test-js": "node tests/js/*.mjs", "test-seshat": "./run-tests.sh" diff --git a/seshatStandardLibrary.ts b/seshatStandardLibrary.ts index 7d1e83e..07b89b7 100644 --- a/seshatStandardLibrary.ts +++ b/seshatStandardLibrary.ts @@ -1,9 +1,9 @@ import { EgyptianNumber } from './egyptianNumber'; -type seshatVariable = EgyptianNumber | string; +type SeshatVariable = EgyptianNumber | string; export function makeSeshatEnvironment(options: { - systemPrint: (...args: any) => void, + systemPrint: (...args: string[]) => void, systemAssert: (expr: boolean) => void, }) { options = { @@ -13,7 +13,7 @@ export function makeSeshatEnvironment(options: { }; return { EgyptianNumber: EgyptianNumber, - print: (...args: Array) => { + print: (...args: SeshatVariable[]) => { const processedArgs = args.map(item => { if (item instanceof EgyptianNumber) { return item.toHieroglyphs(); @@ -23,7 +23,7 @@ export function makeSeshatEnvironment(options: { }) options.systemPrint(...processedArgs); }, - assertEqual: (a: seshatVariable, b: seshatVariable) => { + assertEqual: (a: SeshatVariable, b: SeshatVariable) => { if (a instanceof EgyptianNumber) { options.systemAssert((b instanceof EgyptianNumber) && a.isEqualTo(b)); return;