Skip to content

Commit cf6ce0d

Browse files
committed
feat: add ESLint configuration for Nuxt and NestJS projects
- Introduced a new ESLint configuration file to support both Nuxt and NestJS applications. - Implemented a function to scope files specifically for the web application, ensuring proper linting of relevant file types. - Configured fallback rules for shared TypeScript and JavaScript files, enhancing code quality and consistency across the project.
1 parent 55a3390 commit cf6ce0d

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ $(shell mkdir -p $(CERT_DIR))
3131
.DEFAULT_GOAL := help
3232
help:
3333
@printf "\033[33mUsage:\033[0m\n make [target] [arg=\"val\"...]\n\n\033[33mTargets:\033[0m\n"
34-
@grep -E '^[-a-zA-Z0-9_\.\/]+:.*?## .*$$' $(MAKEFILE_LIST) \
34+
@grep -h -E '^[-a-zA-Z0-9_\.\/]+:.*?## .*$$' $(MAKEFILE_LIST) \
3535
| sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-15s\033[0m %s\n", $$1, $$2}'
3636

3737
build: ## Build the container
@@ -253,3 +253,9 @@ clean-ssl-cert: ## Nettoyer les certificats HTTPS
253253

254254
show-cert-info: ## Afficher les informations du certificat
255255
@openssl x509 -in $(CERT_DIR)/server.crt -text -noout
256+
257+
hibp-key-hex: ## Génère une clé 32 bytes (64 hex chars)
258+
@printf "SESAME_PASSWORD_HISTORY_HIBP_KEY=%s\n" "$$(openssl rand -hex 32)"
259+
260+
hibp-key-b64: ## Génère une clé 32 bytes (base64)
261+
@printf "SESAME_PASSWORD_HISTORY_HIBP_KEY=%s\n" "$$(openssl rand -base64 32)"

eslint.config.mjs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import path from 'node:path'
2+
import { fileURLToPath } from 'node:url'
3+
import { createRequire } from 'node:module'
4+
import { FlatCompat } from '@eslint/eslintrc'
5+
import nuxt from '@nuxt/eslint-config'
6+
7+
const require = createRequire(import.meta.url)
8+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
9+
10+
const compatRoot = new FlatCompat({ baseDirectory: __dirname })
11+
const compatApi = new FlatCompat({ baseDirectory: path.join(__dirname, 'apps/api') })
12+
13+
function scopeFilesToWeb(files) {
14+
if (!Array.isArray(files) || files.length === 0) {
15+
return ['apps/web/**/*.{ts,js,vue}']
16+
}
17+
return files.map((f) => {
18+
if (typeof f !== 'string') return f
19+
if (f.startsWith('!')) return `!apps/web/${f.slice(1)}`
20+
if (f.startsWith('apps/web/')) return f
21+
return `apps/web/${f}`
22+
})
23+
}
24+
25+
const webConfigs = (await nuxt()).map((c) => ({
26+
...c,
27+
files: scopeFilesToWeb(c.files),
28+
}))
29+
30+
export default [
31+
{
32+
ignores: ['**/node_modules/**', '**/dist/**', '**/.output/**', '**/.nuxt/**', '**/coverage/**'],
33+
},
34+
35+
// API (NestJS)
36+
...compatApi.config(require('./apps/api/.eslintrc.js')).map((c) => ({
37+
...c,
38+
files: ['apps/api/**/*.{ts,js}'],
39+
})),
40+
41+
// Web (Nuxt)
42+
...webConfigs,
43+
44+
// Fallback root rules for shared TS/JS (if any)
45+
...compatRoot.config(require('./.eslintrc.js')).map((c) => ({
46+
...c,
47+
files: ['packages/**/*.{ts,js}', 'scripts/**/*.{ts,js}'],
48+
})),
49+
]
50+

0 commit comments

Comments
 (0)