mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
feat: add post-build-script to gradually migrate
This commit is contained in:
1 parent
3977db87a3
commit
8eaec839d3
11 files changed
+624
-154
No files matched your search
+26
-2
@@ -4,22 +4,32 @@ module.exports = {
|
|||||||
node: true,
|
node: true,
|
||||||
jest: true,
|
jest: true,
|
||||||
},
|
},
|
||||||
plugins: ['cypress'],
|
plugins: ['@typescript-eslint', 'cypress'],
|
||||||
extends: [
|
extends: [
|
||||||
'plugin:vue/vue3-essential',
|
'plugin:vue/vue3-essential',
|
||||||
'airbnb-base',
|
'airbnb-base',
|
||||||
'plugin:prettier/recommended', // We added this
|
'plugin:prettier/recommended', // We added this
|
||||||
'plugin:cypress/recommended',
|
'plugin:cypress/recommended',
|
||||||
|
// 'plugin:@typescript-eslint/recommended', // Use recommended rules from the @typescript-eslint/eslint-plugin
|
||||||
],
|
],
|
||||||
|
parser: '@typescript-eslint/parser', // Specify the TypeScript parser
|
||||||
|
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
// parser: 'babel-eslint',
|
// parser: 'babel-eslint',
|
||||||
ecmaVersion: 13,
|
ecmaVersion: 13,
|
||||||
sourceType: 'module',
|
sourceType: 'module',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
settings: {
|
||||||
|
'import/resolver': {
|
||||||
|
node: {
|
||||||
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
rules: {
|
rules: {
|
||||||
'no-console': 'warn',
|
'no-console': 'warn',
|
||||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||||
'import/extensions': 'off',
|
|
||||||
camelcase: ['error', { properties: 'never', ignoreDestructuring: true }],
|
camelcase: ['error', { properties: 'never', ignoreDestructuring: true }],
|
||||||
'no-param-reassign': ['error', { props: false }],
|
'no-param-reassign': ['error', { props: false }],
|
||||||
'no-underscore-dangle': ['error', { allow: ['_id'] }],
|
'no-underscore-dangle': ['error', { allow: ['_id'] }],
|
||||||
@@ -29,5 +39,19 @@ module.exports = {
|
|||||||
'prettier/prettier': ['error', { endOfLine: 'auto', semi: false }],
|
'prettier/prettier': ['error', { endOfLine: 'auto', semi: false }],
|
||||||
'import/prefer-default-export': 'off',
|
'import/prefer-default-export': 'off',
|
||||||
'no-restricted-syntax': ['off', 'ForOfStatement'],
|
'no-restricted-syntax': ['off', 'ForOfStatement'],
|
||||||
|
|
||||||
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||||
|
|
||||||
|
// Allow missing file extensions
|
||||||
|
'import/extensions': [
|
||||||
|
'warn',
|
||||||
|
'ignorePackages',
|
||||||
|
{
|
||||||
|
js: 'never',
|
||||||
|
jsx: 'never',
|
||||||
|
ts: 'never',
|
||||||
|
tsx: 'never',
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
+6
-1
@@ -28,16 +28,21 @@
|
|||||||
"build:quests": "yarn workspace server build:quests"
|
"build:quests": "yarn workspace server build:quests"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/jest": "^29.5.11",
|
||||||
"@types/node": "^20.10.4",
|
"@types/node": "^20.10.4",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
||||||
|
"@typescript-eslint/parser": "^6.14.0",
|
||||||
"@vue/eslint-config-prettier": "^7.1.0",
|
"@vue/eslint-config-prettier": "^7.1.0",
|
||||||
"eslint": "^8.44.0",
|
"eslint": "^8.44.0",
|
||||||
"eslint-config-airbnb-base": "^15.0.0",
|
"eslint-config-airbnb-base": "^15.0.0",
|
||||||
"eslint-config-prettier": "^8.8.0",
|
"eslint-config-prettier": "^8.8.0",
|
||||||
|
"eslint-import-resolver-typescript": "^3.6.1",
|
||||||
"eslint-plugin-cypress": "^2.15.1",
|
"eslint-plugin-cypress": "^2.15.1",
|
||||||
"eslint-plugin-import": "^2.27.5",
|
"eslint-plugin-import": "^2.29.0",
|
||||||
"eslint-plugin-prettier": "^5.0.0",
|
"eslint-plugin-prettier": "^5.0.0",
|
||||||
"eslint-plugin-vue": "^9.15.1",
|
"eslint-plugin-vue": "^9.15.1",
|
||||||
"prettier": "^3.0.0",
|
"prettier": "^3.0.0",
|
||||||
|
"ts-jest": "^29.1.1",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,6 @@
|
|||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc"
|
"build": "tsc && node post-build-script.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import fs from 'fs'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
|
function addJsExtension(filePath) {
|
||||||
|
if (fs.statSync(filePath).isDirectory()) {
|
||||||
|
for (const child of fs.readdirSync(filePath)) {
|
||||||
|
addJsExtension(path.join(filePath, child))
|
||||||
|
}
|
||||||
|
} else if (filePath.endsWith('.js')) {
|
||||||
|
let content = fs.readFileSync(filePath, 'utf8')
|
||||||
|
content = content.replace(/from\s+["']([^"']+)["']/g, (match, group1) => {
|
||||||
|
if (!group1.match(/^[./]|http|https/)) return match // Skip node_modules
|
||||||
|
if (!group1.endsWith('.js')) return `from "${group1}.js"`
|
||||||
|
return match
|
||||||
|
})
|
||||||
|
fs.writeFileSync(filePath, content, 'utf8')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addJsExtension('./dist')
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
/* eslint-disable max-classes-per-file */
|
/* eslint-disable max-classes-per-file */
|
||||||
export class DuplicateItemError extends Error {
|
export class DuplicateItemError extends Error {
|
||||||
constructor(message) {
|
constructor(message: string) {
|
||||||
super(message)
|
super(message)
|
||||||
this.name = 'DuplicateItemError'
|
this.name = 'DuplicateItemError'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ParentNotExistsError extends Error {
|
export class ParentNotExistsError extends Error {
|
||||||
constructor(message) {
|
constructor(message: string) {
|
||||||
super(message)
|
super(message)
|
||||||
this.name = 'ParentNotExistsError'
|
this.name = 'ParentNotExistsError'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FileNotExistsError extends Error {
|
export class FileNotExistsError extends Error {
|
||||||
constructor(message) {
|
constructor(message: string) {
|
||||||
super(message)
|
super(message)
|
||||||
this.name = 'FileNotExistsError'
|
this.name = 'FileNotExistsError'
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
DuplicateItemError,
|
DuplicateItemError,
|
||||||
ParentNotExistsError,
|
ParentNotExistsError,
|
||||||
FileNotExistsError,
|
FileNotExistsError,
|
||||||
} from './errors.js'
|
} from './errors'
|
||||||
import { basename, dirname } from './utils.js'
|
import { basename, dirname } from './utils.js'
|
||||||
|
|
||||||
export default class FileNode extends File {
|
export default class FileNode extends File {
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { DuplicateItemError, ParentNotExistsError } from './errors.js'
|
import { DuplicateItemError, ParentNotExistsError } from './errors'
|
||||||
import FileNode from './fileNode.js'
|
import FileNode from './fileNode.js'
|
||||||
|
|
||||||
function createNodeFromFiles(files) {
|
function createNodeFromFiles(files) {
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "esnext",
|
"target": "ESNext",
|
||||||
"module": "NodeNext",
|
"module": "ESNext",
|
||||||
"moduleResolution": "nodenext",
|
"moduleResolution": "node",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
|
"sourceMap": true,
|
||||||
"allowJs": true
|
"allowJs": true
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": ["src"],
|
||||||
"exclude": ["node_modules", "src/*.test.js", "dist"]
|
"exclude": ["node_modules", "dist"]
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user