Skip to content

Commit

Permalink
chore: format lint and test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeasonstudio committed Dec 26, 2023
1 parent 3eea853 commit 44d4035
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
*.js
*.cjs
*.mjs
*.md
src/antlr4/*
dist/*
Expand Down
3 changes: 2 additions & 1 deletion .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ module.exports = {
'@typescript-eslint/no-parameter-properties': 0,
'@typescript-eslint/no-empty-interface': 0,
'@typescript-eslint/consistent-type-imports': 0,
'@typescript-eslint/no-useless-constructor': 0,
'import/no-extraneous-dependencies': 0,
'no-console': 0,
},
// https://www.npmjs.com/package/@typescript-eslint/parser
parserOptions: {
project: ['tsconfig.json', 'tsconfig.*.json', './packages/**/tsconfig.json'],
project: ['tsconfig.json', 'tsconfig.*.json'],
},
};
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Lint ant prettier
run: pnpm run lint

- name: Build
run: pnpm run build

- name: Run jest
run: pnpm run test:ci

Expand Down
File renamed without changes.
29 changes: 13 additions & 16 deletions jest.config.js → jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
const transform = [
require.resolve('@swc/jest'),
{
jsc: {
parser: {
syntax: 'typescript',
decorators: true,
dynamicImport: true,
},
transform: null,
},
},
];

/** @type {import('jest').Config} */
module.exports = {
testEnvironment: 'node',
Expand All @@ -22,8 +8,19 @@ module.exports = {
modulePathIgnorePatterns: [],
setupFiles: [],
transform: {
'^.+\\.(t|j)s$': transform,
'^.+\\.mjs$': transform,
'^.+\\.m?(t|j)s$': [
require.resolve('@swc/jest'),
{
jsc: {
parser: {
syntax: 'typescript',
decorators: true,
dynamicImport: true,
},
transform: null,
},
},
],
},
collectCoverageFrom: ['<rootDir>/src/**/*.ts'],
coveragePathIgnorePatterns: ['/node_modules/', '/(.*)mock(.*)/', '<rootDir>/src/antlr4'],
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"repository": "[email protected]:jeasonstudio/solidity-antlr4.git",
"lint-staged": {
"*.ts": "eslint --quiet --fix",
"*.{ts,json}": "prettier --loglevel warn --write"
"*.{ts}": "prettier --loglevel warn --write"
},
"dependencies": {
"antlr4ng": "^2.0.4",
Expand Down Expand Up @@ -84,7 +84,7 @@
"test:ci": "jest --coverage --maxWorkers=4 --forceExit",
"lint": "pnpm run \"/^lint:.+/\"",
"lint:eslint": "eslint --quiet --fix --ext .ts .",
"lint:prettier": "prettier --log-level warn --write '**/*.{ts,tsx,json}'",
"lint:prettier": "prettier **/*.ts --log-level warn --write",
"husky:prepare": "husky install",
"husky:pre-commit": "lint-staged"
}
Expand Down
9 changes: 8 additions & 1 deletion src/ast/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import { StatementNode, StatementNodeType } from './statement';
import { TypeNode, TypeNodeType } from './type';
import { YulNode, YulNodeType } from './yul';

export type SyntaxNode = DeclarationNode | ExpressionNode | MetaNode | StatementNode | TypeNode | YulNode;
export type SyntaxNode =
| DeclarationNode
| ExpressionNode
| MetaNode
| StatementNode
| TypeNode
| YulNode;

export type SyntaxNodeType =
| DeclarationNodeType
| ExpressionNodeType
Expand Down
4 changes: 3 additions & 1 deletion src/tests/statement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ test('forStatement', () => {
});

test('block', () => {
expect(createParse((p) => p.block())(`{ break; unchecked { return; } { continue; } }`)).toMatchObject({
expect(
createParse((p) => p.block())(`{ break; unchecked { return; } { continue; } }`),
).toMatchObject({
statements: [{}, {}],
uncheckedBlocks: [{}],
});
Expand Down

0 comments on commit 44d4035

Please sign in to comment.