Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve and fix formatter, linter and test suite #19

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "none",
"jsxBracketSameLine": true,
"bracketSameLine": true,
"bracketSpacing": true,
"arrowParens": "avoid",
"printWidth": 120
}

Binary file removed Intellij_Jest_config.png
Binary file not shown.
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,26 @@ yarn
```

## IntelliJ IDEA Setup
- Adjust node version: `Preferences` -> `Languages & Frameworks` -> `Node.js and NPM` and set the `Node interpreter` to the path of your Node.js installation.
- Configure jest: `Run/debug configurations` -> `Add new configuration` -> `Jest` and set the `Jest package` to the path of your `jest` installation.'

![jestconfig.png](Intellij_Jest_config.png)
- Adjust node version: `Preferences` -> `Languages & Frameworks` -> `Node.js and NPM` and set the `Node interpreter` to the path of your Node.js installation.

## Scripts

| Command | Description |
|-------------------|------------------------------------|
| `yarn test` | Run all tests. |
| `yarn test:watch` | Run tests in watch mode. |
| `yarn lint` | Check for linting issues. |
| `yarn lint --fix` | Fix linting issues automatically. |
| Command | Description |
| ----------------- | --------------------------------- |
| `yarn test` | Run all tests. |
| `yarn test:watch` | Run tests in watch mode. |
| `yarn lint` | Check for linting issues. |
| `yarn lint --fix` | Fix linting issues automatically. |

## Folder Structure

```
tdd-ts/
├── src/ # Source code
├── test/ # Test files
├── .eslintignore # Files to ignore during linting
├── eslint.config.js # ESLint configuration
├── jest-config.json # Jest configuration
├── jest.config.json # Jest configuration
├── tsconfig.json # TypeScript configuration
├── package.json # Project metadata and scripts
└── README.md # Documentation
Expand Down
16 changes: 13 additions & 3 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'
import prettier from 'eslint-config-prettier'
import jest from 'eslint-plugin-jest'

export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommended,
);
{
files: ['test/**'],
...jest.configs['flat/recommended'],
rules: {
...jest.configs['flat/recommended'].rules
}
},
prettier
)
File renamed without changes.
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,18 @@
"@eslint/js": "^9.16.0",
"@types/jest": "^29.5.4",
"@types/node": "^20.8.6",
"@typescript-eslint/eslint-plugin": "^8.16.0",
"@typescript-eslint/parser": "^8.16.0",
"eslint": "^9.16.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^28.9.0",
"jest": "^29.7.0",
"prettier": "^3.0.3",
"ts-jest": "^29.1.1",
"ts-jest": "^29.2.5",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.0"
},
"scripts": {
"lint": "eslint .",
"test": "jest -c jest-config.json",
"test:watch": "jest -c jest-config.json --watch"
"test": "jest",
"test:watch": "jest --watch"
}
}
12 changes: 6 additions & 6 deletions src/calculator.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export default class Calculator {
add(number1: number, number2: number): number {
return 0
}
add(number1: number, number2: number): number {
return 0
}

multiply(number1: number, number2: number): number {
return 0
}
multiply(number1: number, number2: number): number {
return 0
}
}
14 changes: 7 additions & 7 deletions test/calculator.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Calculator from '../src/calculator'

describe('Calculator', () => {
const calculator = new Calculator()
const calculator = new Calculator()

it('should add two numbers', () => {
expect(calculator.add(1, 2)).toEqual(3)
})
it('should add two numbers', () => {
expect(calculator.add(1, 2)).toEqual(3)
})

it('should multiply two numbers', () => {
expect(calculator.multiply(1, 2)).toEqual(2)
})
it('should multiply two numbers', () => {
expect(calculator.multiply(1, 2)).toEqual(2)
})
})
Loading