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

[Tech] Migrer le Frontend vers l'ESM #1861

Merged
merged 1 commit into from
Nov 18, 2024
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
12 changes: 9 additions & 3 deletions frontend/.eslintrc.js → frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
ecmaVersion: 2022,
project: path.join(__dirname, 'tsconfig.json')
},
ignorePatterns: ['.eslintrc.js', '.eslintrc.partial.js'],
ignorePatterns: ['.eslintrc.cjs'],
env: {
browser: true
},
Expand Down Expand Up @@ -138,7 +138,7 @@ module.exports = {
files: ['**/*.test.ts', '**/*.test.tsx', 'puppeteer/**/*.ts'],
plugins: ['jest'],
env: {
jest: true,
jest: true
},
rules: {
'jest/no-disabled-tests': 'error',
Expand All @@ -151,7 +151,7 @@ module.exports = {
'no-restricted-syntax': 'off',
'no-underscore-dangle': 'off',
'import/no-default-export': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-extraneous-dependencies': 'off'
}
},

Expand Down Expand Up @@ -199,6 +199,12 @@ module.exports = {
env: {
browser: false,
node: true
},
rules: {
'import/no-default-export': 'off',
'import/no-extraneous-dependencies': 'off',

'@typescript-eslint/naming-convention': 'off'
}
}
]
Expand Down
5 changes: 2 additions & 3 deletions frontend/config/fileTransformer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const path = require('path')

import path from 'path'
// https://jestjs.io/docs/code-transformation#examples

module.exports = {
export default {
process(sourceText, sourcePath) {
return {
code: `module.exports = ${JSON.stringify(path.basename(sourcePath))};`
Expand Down
2 changes: 1 addition & 1 deletion frontend/config/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
clearMocks: true,
collectCoverageFrom: ['**/{hooks,libs,utils}/**/*.t{s,sx}', '**/utils.ts'],
globalSetup: '<rootDir>/config/jest.global.js',
Expand Down
2 changes: 1 addition & 1 deletion frontend/config/jest.global.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @see https://jestjs.io/docs/configuration#globalsetup-string
*/
module.exports = () => {
export default () => {
process.env.TZ = 'America/New_York'
}
2 changes: 1 addition & 1 deletion frontend/config/multi-windows/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
globalSetup: '<rootDir>/puppeteer/setup.ts',
// because it's detected by the default value of testRegex
// https://jestjs.io/docs/configuration#testregex-string--arraystring
Expand Down
3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"license": "AGPL-3.0",
"private": true,
"type": "module",
"engines": {
"node": "20",
"npm": "10"
Expand All @@ -16,7 +17,7 @@
"start": "vite preview --port 3000",
"test:e2e": "cypress run --browser firefox --config-file ./config/cypress.config.ts --e2e",
"test:e2e:open": "cypress open --browser firefox --config-file ./config/cypress.config.ts --e2e",
"test:lint": "eslint ./src",
"test:lint": "eslint --config=./.eslintrc.cjs ./src",
"test:lint:fix": "npm run test:lint -- --fix",
"test:multi-windows:open": "IS_HEADLESS=false jest --config=./config/multi-windows/jest.config.js",
"test:multi-windows:run": "IS_HEADLESS=true jest --config=./config/multi-windows/jest.config.js",
Expand Down
9 changes: 7 additions & 2 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
"useUnknownInCatchVariables": true,
"verbatimModuleSyntax": true
},
"include": ["**/*.js", "**/*.jsx", "**/*.mjs", "**/*.mts", "**/*.ts", "**/*.tsx", "vite.config.mts"],
"exclude": ["node_modules/*"]
"include": ["**/*.cjs", "**/*.cts", "**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx", "vite.config.ts"],
"exclude": ["node_modules/*"],
"ts-node": {
"esm": true,
"swc": true,
"transpileOnly": true
}
}
File renamed without changes.
Loading