init
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['./eslint/lib'],
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all",
|
||||
"printWidth": 100,
|
||||
"proseWrap": "never",
|
||||
"endOfLine": "auto",
|
||||
"semi": true,
|
||||
"tabWidth": 4,
|
||||
"overrides": [
|
||||
{
|
||||
"files": ".prettierrc",
|
||||
"options": {
|
||||
"parser": "json"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
module.exports = {
|
||||
parserOptions: {
|
||||
// React启用jsx
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
globals: {
|
||||
React: true,
|
||||
JSX: true,
|
||||
page: true,
|
||||
REACT_APP_ENV: true,
|
||||
},
|
||||
extends: ['./react-lib'],
|
||||
rules: {
|
||||
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['@typescript-eslint', 'import', 'unused-imports', 'prettier'],
|
||||
extends: [
|
||||
// typescript的eslint插件
|
||||
// https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md
|
||||
// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
||||
'./base',
|
||||
],
|
||||
rules: {
|
||||
'@typescript-eslint/no-unused-vars': 0,
|
||||
'@typescript-eslint/no-empty-interface': 0,
|
||||
'@typescript-eslint/no-this-alias': 0,
|
||||
'@typescript-eslint/no-var-requires': 0,
|
||||
'@typescript-eslint/no-use-before-define': 0,
|
||||
'@typescript-eslint/explicit-member-accessibility': 0,
|
||||
'@typescript-eslint/no-non-null-assertion': 0,
|
||||
'@typescript-eslint/no-unnecessary-type-assertion': 0,
|
||||
'@typescript-eslint/require-await': 0,
|
||||
'@typescript-eslint/no-for-in-array': 0,
|
||||
'@typescript-eslint/interface-name-prefix': 0,
|
||||
'@typescript-eslint/explicit-function-return-type': 0,
|
||||
'@typescript-eslint/no-explicit-any': 0,
|
||||
'@typescript-eslint/explicit-module-boundary-types': 0,
|
||||
'@typescript-eslint/no-floating-promises': 0,
|
||||
'@typescript-eslint/restrict-template-expressions': 0,
|
||||
'@typescript-eslint/no-unsafe-assignment': 0,
|
||||
'@typescript-eslint/no-unsafe-return': 0,
|
||||
'@typescript-eslint/no-unused-expressions': 0,
|
||||
'@typescript-eslint/no-misused-promises': 0,
|
||||
'@typescript-eslint/no-unsafe-member-access': 0,
|
||||
'@typescript-eslint/no-unsafe-call': 0,
|
||||
'@typescript-eslint/no-unsafe-argument': 0,
|
||||
'@typescript-eslint/ban-ts-comment': 0,
|
||||
'@typescript-eslint/naming-convention': 0,
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
module.exports = {
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
},
|
||||
plugins: ['prettier', 'import', 'unused-imports'],
|
||||
extends: [
|
||||
// 使用prettier格式化代码
|
||||
// https://github.com/prettier/eslint-config-prettier#readme
|
||||
'prettier',
|
||||
// 整合typescript-eslint与prettier
|
||||
// https://github.com/prettier/eslint-plugin-prettier
|
||||
'plugin:prettier/recommended',
|
||||
'eslint-config-turbo',
|
||||
],
|
||||
rules: {
|
||||
/* ********************************** ES6+ ********************************** */
|
||||
'no-console': 0,
|
||||
'no-var-requires': 0,
|
||||
'no-restricted-syntax': 0,
|
||||
'no-continue': 0,
|
||||
'no-await-in-loop': 0,
|
||||
'no-return-await': 0,
|
||||
'no-unused-vars': 0,
|
||||
'no-multi-assign': 0,
|
||||
'no-param-reassign': [2, { props: false }],
|
||||
'import/prefer-default-export': 0,
|
||||
'import/no-cycle': 0,
|
||||
'import/no-dynamic-require': 0,
|
||||
'max-classes-per-file': 0,
|
||||
'class-methods-use-this': 0,
|
||||
'guard-for-in': 0,
|
||||
'no-underscore-dangle': 0,
|
||||
'no-plusplus': 0,
|
||||
'no-lonely-if': 0,
|
||||
'no-bitwise': ['error', { allow: ['~'] }],
|
||||
|
||||
/* ********************************** Module Import ********************************** */
|
||||
|
||||
'import/no-absolute-path': 0,
|
||||
'import/extensions': 0,
|
||||
'import/no-named-default': 0,
|
||||
'no-restricted-exports': 0,
|
||||
'import/no-extraneous-dependencies': 0,
|
||||
// 模块导入顺序规则
|
||||
'import/order': [
|
||||
1,
|
||||
{
|
||||
pathGroups: [
|
||||
{
|
||||
pattern: '@/**',
|
||||
group: 'external',
|
||||
position: 'after',
|
||||
},
|
||||
],
|
||||
alphabetize: { order: 'asc', caseInsensitive: false },
|
||||
'newlines-between': 'always-and-inside-groups',
|
||||
warnOnUnassignedImports: true,
|
||||
},
|
||||
],
|
||||
// 自动删除未使用的导入
|
||||
// https://github.com/sweepline/eslint-plugin-unused-imports
|
||||
'unused-imports/no-unused-imports': 1,
|
||||
'unused-imports/no-unused-vars': [
|
||||
'error',
|
||||
{
|
||||
vars: 'all',
|
||||
args: 'none',
|
||||
ignoreRestSiblings: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
module.exports = {
|
||||
extends: [
|
||||
// airbnb规范
|
||||
// https://www.npmjs.com/package/eslint-config-airbnb-base
|
||||
'airbnb-base',
|
||||
// 兼容typescript的airbnb规范
|
||||
// https://github.com/iamturns/eslint-config-airbnb-typescript
|
||||
'airbnb-typescript/base',
|
||||
'./base-ts',
|
||||
],
|
||||
env: {
|
||||
node: true,
|
||||
},
|
||||
ignorePatterns: [
|
||||
// Ignore dotfiles
|
||||
'node_modules/',
|
||||
'dist/',
|
||||
],
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.js?(x)', '*.ts?(x)', '*.json'],
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
module.exports = {
|
||||
extends: [
|
||||
// airbnb规范
|
||||
// https://www.npmjs.com/package/eslint-config-airbnb-base
|
||||
'airbnb-base',
|
||||
'./base',
|
||||
],
|
||||
env: {
|
||||
node: true,
|
||||
},
|
||||
ignorePatterns: [
|
||||
// Ignore dotfiles
|
||||
'node_modules/',
|
||||
],
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.js?(x)', '*.json'],
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
module.exports = {
|
||||
env: {
|
||||
node: true,
|
||||
jest: true,
|
||||
},
|
||||
plugins: ['@typescript-eslint', 'jest', 'import', 'unused-imports', 'prettier'],
|
||||
extends: [
|
||||
// 支持jest
|
||||
'plugin:jest/recommended',
|
||||
'./lib-ts',
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
const { resolve } = require('node:path');
|
||||
|
||||
const project = resolve(process.cwd(), 'tsconfig.eslint.json');
|
||||
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
module.exports = {
|
||||
env: {
|
||||
node: true,
|
||||
browser: true,
|
||||
},
|
||||
globals: {
|
||||
React: true,
|
||||
JSX: true,
|
||||
},
|
||||
extends: ['plugin:@next/next/recommended', './base-ts'],
|
||||
settings: {
|
||||
'import/resolver': {
|
||||
typescript: {
|
||||
project,
|
||||
},
|
||||
},
|
||||
},
|
||||
ignorePatterns: [
|
||||
// Ignore dotfiles
|
||||
'node_modules/',
|
||||
],
|
||||
};
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
module.exports = {
|
||||
parserOptions: {
|
||||
// 指定ESLint可以解析JSX语法
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
// React启用jsx
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
extends: [
|
||||
// airbnb规范
|
||||
// https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb
|
||||
'airbnb',
|
||||
// 兼容typescript的airbnb规范
|
||||
// https://github.com/iamturns/eslint-config-airbnb-typescript
|
||||
'airbnb-typescript',
|
||||
// react hooks的airbnb规范
|
||||
'airbnb/hooks',
|
||||
'./base-ts',
|
||||
],
|
||||
env: {
|
||||
node: true,
|
||||
browser: true,
|
||||
},
|
||||
plugins: ['@typescript-eslint', 'react-refresh', 'import', 'unused-imports', 'prettier'],
|
||||
ignorePatterns: [
|
||||
// Ignore dotfiles
|
||||
'node_modules/',
|
||||
'dist/',
|
||||
],
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.js?(x)', '*.ts?(x)', '*.json'],
|
||||
},
|
||||
],
|
||||
rules: {
|
||||
/* ********************************** React and Hooks ********************************** */
|
||||
'react/jsx-uses-react': 1,
|
||||
'react/jsx-uses-vars': 1,
|
||||
'react/jsx-no-useless-fragment': 0,
|
||||
'react/display-name': 0,
|
||||
'react/button-has-type': 0,
|
||||
'react/prop-types': 0,
|
||||
'react/jsx-props-no-spreading': 0,
|
||||
'react/destructuring-assignment': 0,
|
||||
'react/static-property-placement': 0,
|
||||
'react/react-in-jsx-scope': 0,
|
||||
'react/require-default-props': 0,
|
||||
'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }],
|
||||
'react/function-component-definition': 0,
|
||||
'react-hooks/exhaustive-deps': 0,
|
||||
|
||||
/* ********************************** jax-a11y ********************************** */
|
||||
'jsx-a11y/anchor-is-valid': 0,
|
||||
'jsx-a11y/no-static-element-interactions': 0,
|
||||
'jsx-a11y/click-events-have-key-events': 0,
|
||||
'jsx-a11y/label-has-associated-control': [
|
||||
'error',
|
||||
{
|
||||
required: {
|
||||
some: ['nesting', 'id'],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
extends: ['./react-lib'],
|
||||
env: { browser: true, es2024: true },
|
||||
rules: {
|
||||
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "@3rapp/code-config",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"files": [
|
||||
"eslint/*.js",
|
||||
"stylelint/*.js",
|
||||
"tsconfig"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@next/eslint-plugin-next": "^14.2.3",
|
||||
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
||||
"@typescript-eslint/parser": "^7.8.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"eslint-config-airbnb-typescript": "^18.0.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-config-turbo": "^1.13.3",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-jest": "^28.5.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.8.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"eslint-plugin-react": "^7.34.1",
|
||||
"eslint-plugin-react-hooks": "^4.6.2",
|
||||
"eslint-plugin-react-refresh": "^0.4.6",
|
||||
"eslint-plugin-unused-imports": "^3.2.0",
|
||||
"prettier": "^3.2.5",
|
||||
"stylelint": "^16.5.0",
|
||||
"stylelint-config-css-modules": "^4.4.0",
|
||||
"stylelint-config-recess-order": "^5.0.1",
|
||||
"stylelint-config-standard": "^36.0.0",
|
||||
"stylelint-prettier": "^5.0.0",
|
||||
"typescript": "^5.4.5"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// .stylelintrc.js
|
||||
module.exports = {
|
||||
extends: [
|
||||
'stylelint-config-standard',
|
||||
'stylelint-config-css-modules',
|
||||
'stylelint-config-recess-order',
|
||||
'stylelint-prettier/recommended',
|
||||
],
|
||||
rules: {
|
||||
'import-notation': 'string', // 使用string方式引入其它css文件,而不是url()
|
||||
'selector-type-no-unknown': null,
|
||||
'selector-class-pattern': null,
|
||||
'custom-property-pattern': null,
|
||||
'no-duplicate-selectors': null, // 取消禁止重复定义,这样可以在css module中单独定义变量
|
||||
'block-no-empty': null, // 禁止出现空块
|
||||
'declaration-empty-line-before': 'never',
|
||||
'declaration-block-no-duplicate-properties': true, // 在声明的块中中禁止出现重复的属性
|
||||
'declaration-block-no-redundant-longhand-properties': true, // 禁止使用可以缩写却不缩写的属性
|
||||
'shorthand-property-no-redundant-values': true, // 禁止在简写属性中使用冗余值
|
||||
'color-hex-length': 'short', // 指定十六进制颜色是否使用缩写
|
||||
'comment-no-empty': true, // 禁止空注释
|
||||
'font-family-name-quotes': 'always-unless-keyword', // 指定字体名称是否需要使用引号引起来 | 期待每一个不是关键字的字体名都使用引号引起来
|
||||
// 'font-weight-notation': 'numeric', // 要求使用数字或命名的 (可能的情况下) font-weight 值
|
||||
'function-url-quotes': 'always', // 要求或禁止 url 使用引号
|
||||
'property-no-vendor-prefix': true, // 禁止属性使用浏览器引擎前缀
|
||||
'value-no-vendor-prefix': true, // 禁止给值添加浏览器引擎前缀
|
||||
'selector-no-vendor-prefix': true, // 禁止使用浏览器引擎前缀
|
||||
'no-descending-specificity': null, // 禁止低优先级的选择器出现在高优先级的选择器之后
|
||||
'at-rule-no-unknown': [
|
||||
true,
|
||||
{
|
||||
ignoreAtRules: ['layer', 'apply', 'screen', 'define-mixin', 'mixin'],
|
||||
},
|
||||
],
|
||||
|
||||
'property-no-unknown': [
|
||||
true,
|
||||
{
|
||||
ignoreProperties: [
|
||||
// CSS Modules composition
|
||||
// https://github.com/css-modules/css-modules#composition
|
||||
'composes',
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
'selector-pseudo-class-no-unknown': [
|
||||
true,
|
||||
{
|
||||
ignorePseudoClasses: [
|
||||
// CSS Modules :global scope
|
||||
// https://github.com/css-modules/css-modules#exceptions
|
||||
'global',
|
||||
'local',
|
||||
],
|
||||
},
|
||||
],
|
||||
'rule-empty-line-before': [
|
||||
// 要求或禁止在规则声明之前有空行
|
||||
'always-multi-line',
|
||||
{
|
||||
except: ['first-nested'],
|
||||
ignore: ['after-comment'],
|
||||
},
|
||||
],
|
||||
'at-rule-empty-line-before': [
|
||||
// 要求或禁止在 at 规则之前有空行
|
||||
'always',
|
||||
{
|
||||
except: ['blockless-after-same-name-blockless', 'first-nested'],
|
||||
ignore: ['after-comment'],
|
||||
},
|
||||
],
|
||||
'comment-empty-line-before': [
|
||||
// 要求或禁止在注释之前有空行
|
||||
'always',
|
||||
{
|
||||
except: ['first-nested'],
|
||||
ignore: ['stylelint-commands'],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"display": "Antd pro",
|
||||
"extends": "./base.json",
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"module": "esnext",
|
||||
"importHelpers": true,
|
||||
"jsx": "preserve"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"display": "Default",
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"alwaysStrict": true,
|
||||
"target": "esnext",
|
||||
"moduleResolution": "Node",
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"sourceMap": true,
|
||||
"incremental": true,
|
||||
"skipLibCheck": true,
|
||||
"strictNullChecks": false,
|
||||
"noImplicitAny": true,
|
||||
"strictBindCallApply": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": false,
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"noUnusedLocals": true,
|
||||
"noImplicitReturns": true,
|
||||
"pretty": true,
|
||||
"resolveJsonModule": true,
|
||||
"importsNotUsedAsValues": "remove"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"display": "Next.js",
|
||||
"extends": "./base.json",
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"noEmit": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"jsx": "preserve",
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"display": "Node.js",
|
||||
"extends": "./base.json",
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"module": "commonjs",
|
||||
"noEmit": false,
|
||||
"declaration": true,
|
||||
"declarationMap": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"display": "Vite React",
|
||||
"extends": "./base.json",
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"removeComments": true,
|
||||
"experimentalDecorators": true,
|
||||
"alwaysStrict": true,
|
||||
"sourceMap": true,
|
||||
"incremental": true,
|
||||
"noImplicitReturns": true,
|
||||
"pretty": true,
|
||||
"noImplicitAny": true,
|
||||
"importsNotUsedAsValues": "remove",
|
||||
|
||||
"emitDecoratorMetadata": true,
|
||||
"strictNullChecks": false,
|
||||
"strictBindCallApply": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
dist
|
||||
node_modules
|
||||
pnpm-lock.yaml
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
docker
|
||||
Dockerfile*
|
||||
LICENSE
|
||||
yarn-error.log
|
||||
.history
|
||||
.vscode
|
||||
.dockerignore
|
||||
.DS_Store
|
||||
.eslintignore
|
||||
.editorconfig
|
||||
.gitignore
|
||||
.prettierignore
|
||||
.eslintcache
|
||||
*.lock
|
||||
**/*.svg
|
||||
**/*.md
|
||||
**/*.svg
|
||||
**/*.ejs
|
||||
**/*.html
|
||||
**/*.png
|
||||
**/*.toml
|
||||
@@ -0,0 +1,8 @@
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
module.exports = {
|
||||
root: true,
|
||||
parserOptions: {
|
||||
project: true,
|
||||
},
|
||||
extends: [require.resolve('@3rapp/code-config/eslint/lib-ts')],
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
# compiled output
|
||||
/dist
|
||||
/node_modules
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
pnpm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
|
||||
# Tests
|
||||
/coverage
|
||||
/.nyc_output
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# IDE - VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
@@ -0,0 +1,26 @@
|
||||
dist
|
||||
node_modules
|
||||
pnpm-lock.yaml
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
docker
|
||||
Dockerfile*
|
||||
LICENSE
|
||||
yarn-error.log
|
||||
.history
|
||||
.vscode
|
||||
.dockerignore
|
||||
.DS_Store
|
||||
.eslintignore
|
||||
.editorconfig
|
||||
.gitignore
|
||||
.prettierignore
|
||||
.eslintcache
|
||||
*.lock
|
||||
**/*.svg
|
||||
**/*.md
|
||||
**/*.svg
|
||||
**/*.ejs
|
||||
**/*.html
|
||||
**/*.png
|
||||
**/*.toml
|
||||
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all",
|
||||
"printWidth": 100,
|
||||
"proseWrap": "never",
|
||||
"endOfLine": "auto",
|
||||
"semi": true,
|
||||
"tabWidth": 4,
|
||||
"overrides": [
|
||||
{
|
||||
"files": ".prettierrc",
|
||||
"options": {
|
||||
"parser": "json"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@3rapp/utils",
|
||||
"version": "0.0.0",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"main": "./dist/cjs/index.js",
|
||||
"module": "./dist/es/index.mjs",
|
||||
"types": "./dist/cjs/index.d.ts",
|
||||
"exports": {
|
||||
"import": {
|
||||
"types": "./dist/es/index.d.ts",
|
||||
"default": "./dist/es/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/cjs/index.d.cts",
|
||||
"default": "./dist/cjs/index.cjs"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "bunchee -w --tsconfig tsconfig.build.json",
|
||||
"build": "bunchee --tsconfig tsconfig.build.json",
|
||||
"lint": "eslint . --ext ts,tsx"
|
||||
},
|
||||
"dependencies": {
|
||||
"deepmerge": "^4.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@3rapp/code-config": "workspace:*",
|
||||
"@types/node": "^20.12.10",
|
||||
"bunchee": "^5.1.5",
|
||||
"eslint": "^8.57.0",
|
||||
"typescript": "^5.4.5"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from './tools';
|
||||
@@ -0,0 +1,31 @@
|
||||
import { resolve } from 'path';
|
||||
|
||||
import deepmerge from 'deepmerge';
|
||||
|
||||
/**
|
||||
* 深度合并对象
|
||||
* @param x 初始值
|
||||
* @param y 新值
|
||||
* @param arrayMode 对于数组采取的策略,`replace`为直接替换,`merge`为合并数组
|
||||
*/
|
||||
export const deepMerge = <T1, T2>(
|
||||
x: Partial<T1>,
|
||||
y: Partial<T2>,
|
||||
arrayMode: 'replace' | 'merge' = 'merge',
|
||||
) => {
|
||||
const options: deepmerge.Options = {};
|
||||
if (arrayMode === 'replace') {
|
||||
options.arrayMerge = (_d, s, _o) => s;
|
||||
} else if (arrayMode === 'merge') {
|
||||
options.arrayMerge = (_d, s, _o) => Array.from(new Set([..._d, ...s]));
|
||||
}
|
||||
return deepmerge(x, y, options) as T2 extends T1 ? T1 : T1 & T2;
|
||||
};
|
||||
|
||||
export const pathResolve = (dir: string) => {
|
||||
const { stack } = new Error();
|
||||
const stackLines = stack.split('\n');
|
||||
const callerLine = stackLines[2].trim();
|
||||
const callerFilePath = callerLine.match(/\(([^:)]+):/)[1];
|
||||
return resolve(callerFilePath, '../', dir);
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts", "**.js"]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "@3rapp/code-config/typescript/nodejs.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src", "test", "typings/**/*.d.ts", "**.js"]
|
||||
}
|
||||
Reference in New Issue
Block a user