Skip to content
Merged
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
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

11 changes: 0 additions & 11 deletions .eslintrc.json

This file was deleted.

14 changes: 14 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import digabiConfig from '@digabi/eslint-config'

export default [
{
ignores: ['**/*.snapshot']
},
...digabiConfig(),
{
files: ['**/*.test.ts'],
rules: {
'@typescript-eslint/no-floating-promises': 'off'
}
}
]
6,404 changes: 3,457 additions & 2,947 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
"packages/*"
],
"devDependencies": {
"@digabi/eslint-config": "^3.3.0",
"@digabi/eslint-config": "^3.4.0",
"@digabi/typescript-config": "^1.0.2",
"@types/node": "^24.10.9",
"@typescript-eslint/eslint-plugin": "^8.38.0",
"@typescript-eslint/parser": "^8.38.0",
"eslint": "^8.45.0",
"eslint": "^9.0.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-import-x": "^4.6.0",
"eslint-plugin-prettier": "^5.5.3",
"eslint-plugin-promise": "^7.2.1",
"globals": "^16.0.0",
"lerna": "^9.0.0",
"prettier": "^3.6.2",
"tsx": "^4.20.3",
"typescript": "^5.8.3"
"typescript": "^5.8.3",
"typescript-eslint": "^8.58.0"
},
"scripts": {
"build": "lerna run build",
Expand Down
2 changes: 1 addition & 1 deletion packages/2fa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"build": "tsc --project ./tsconfig.build.json",
"test": "node --test --import tsx ./__tests__/*.test.ts",
"lint": "tsc --noEmit && eslint --ignore-path ../../.eslintignore ./",
"lint": "tsc --noEmit && eslint ./",
"prepare": "npm run build"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/answer-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"build": "tsc --project ./tsconfig.build.json",
"test": "node --test --import tsx ./__tests__/*.test.ts",
"lint": "tsc --noEmit && eslint --ignore-path ../../.eslintignore ./",
"lint": "tsc --noEmit && eslint ./",
"prepare": "npm run build"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/async-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"build": "tsc --project ./tsconfig.build.json",
"test": "node --test --import tsx ./__tests__/*.test.ts",
"lint": "tsc --noEmit && eslint --ignore-path ../../.eslintignore ./",
"lint": "tsc --noEmit && eslint ./",
"prepare": "npm run build"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/crypto-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"build": "tsc --project ./tsconfig.build.json",
"test": "node --test --import tsx ./__tests__/*.test.ts",
"lint": "tsc --noEmit && eslint --ignore-path ../../.eslintignore ./",
"lint": "tsc --noEmit && eslint ./",
"prepare": "npm run build"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/database-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"scripts": {
"build": "tsc --project ./tsconfig.build.json",
"test": "TZ=UTC node --test --import tsx ./__tests__/*.test.ts",
"lint": "tsc --noEmit && eslint --ignore-path ../../.eslintignore ./",
"lint": "tsc --noEmit && eslint ./",
"prepare": "npm run build"
},
"publishConfig": {
Expand Down
25 changes: 14 additions & 11 deletions packages/eslint-config/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
# eslint-config

Shared ESLint config for the digabi project.
Shared ESLint config for the digabi project. Requires ESLint 9+ and uses the flat config format.

# How to add to a new project?

Add the required dependencies:

$ npm install --save-dev @digabi/eslint-config @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-config-prettier eslint-plugin-import eslint-plugin-prettier
$ npm install --save-dev @digabi/eslint-config eslint eslint-plugin-import-x eslint-plugin-prettier eslint-plugin-promise globals typescript-eslint

If you're using React, add

$ npm install --save-dev eslint-plugin-react
$ npm install --save-dev eslint-plugin-react-hooks
$ npm install --save-dev eslint-plugin-react eslint-plugin-react-hooks

If you're using Mocha, add

$ npm install --save-dev eslint-plugin-mocha
$ npm install --save-dev eslint-plugin-mocha mocha

If you're using Jest, add

$ npm install --save-dev eslint-plugin-jest
$ npm install --save-dev eslint-plugin-jest jest

Finally, add or modify `.eslintrc.json` in the project root.
Create an `eslint.config.mjs` in the project root:

```json
{
"extends": "@digabi/eslint-config"
}
```js
import digabiConfig from '@digabi/eslint-config'

export default [
...digabiConfig(),
]
```

The config auto-detects installed optional plugins (React, Mocha, Jest) and enables their rules automatically.
43 changes: 43 additions & 0 deletions packages/eslint-config/__tests__/eslint-config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { describe, test } from 'node:test'
import { ESLint } from 'eslint'
import digabiConfig from '../src/index.mjs'

function sortKeysDeep(obj: unknown, seen = new WeakSet()): unknown {
if (Array.isArray(obj)) return obj.map(item => sortKeysDeep(item, seen))
if (obj !== null && typeof obj === 'object') {
if (seen.has(obj)) return '[Circular]'
seen.add(obj)
return Object.keys(obj as Record<string, unknown>)
.sort()
.reduce<Record<string, unknown>>((sorted, key) => {
sorted[key] = sortKeysDeep((obj as Record<string, unknown>)[key], seen)
return sorted
}, {})
}
return obj
}

function normalizeConfig(resolved: Record<string, unknown>) {
return sortKeysDeep(resolved)
}

function createESLint(cwd?: string) {
return new ESLint({
overrideConfigFile: true,
overrideConfig: digabiConfig(),
cwd: cwd ?? process.cwd()
})
}

const FILE_TYPES = ['test.js', 'test.ts', 'test.tsx', 'test.spec.ts']

describe('eslint-config (all plugins enabled)', () => {
for (const fileType of FILE_TYPES) {
test(`resolved config for ${fileType}`, async t => {
const eslint = createESLint()
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const resolved: { rules: any } = await eslint.calculateConfigForFile(fileType)
t.assert.snapshot(normalizeConfig(resolved.rules as unknown as Record<string, unknown>))
})
}
})
Loading
Loading