更新最新代码
This commit is contained in:
7
internal/lint-configs/eslint-config/build.config.ts
Normal file
7
internal/lint-configs/eslint-config/build.config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { defineBuildConfig } from 'unbuild';
|
||||
|
||||
export default defineBuildConfig({
|
||||
clean: true,
|
||||
declaration: true,
|
||||
entries: ['src/index'],
|
||||
});
|
||||
56
internal/lint-configs/eslint-config/package.json
Normal file
56
internal/lint-configs/eslint-config/package.json
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"name": "@vben/eslint-config",
|
||||
"version": "5.0.0",
|
||||
"private": true,
|
||||
"homepage": "https://github.com/vbenjs/vue-vben-admin",
|
||||
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vbenjs/vue-vben-admin.git",
|
||||
"directory": "internal/lint-configs/eslint-config"
|
||||
},
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"stub": "pnpm unbuild --stub"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"main": "./dist/index.mjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"eslint-config-turbo": "catalog:",
|
||||
"eslint-plugin-command": "catalog:",
|
||||
"eslint-plugin-import-x": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "catalog:",
|
||||
"@types/eslint": "catalog:",
|
||||
"@typescript-eslint/eslint-plugin": "catalog:",
|
||||
"@typescript-eslint/parser": "catalog:",
|
||||
"eslint": "catalog:",
|
||||
"eslint-plugin-eslint-comments": "catalog:",
|
||||
"eslint-plugin-jsdoc": "catalog:",
|
||||
"eslint-plugin-jsonc": "catalog:",
|
||||
"eslint-plugin-n": "catalog:",
|
||||
"eslint-plugin-no-only-tests": "catalog:",
|
||||
"eslint-plugin-perfectionist": "catalog:",
|
||||
"eslint-plugin-prettier": "catalog:",
|
||||
"eslint-plugin-regexp": "catalog:",
|
||||
"eslint-plugin-unicorn": "catalog:",
|
||||
"eslint-plugin-unused-imports": "catalog:",
|
||||
"eslint-plugin-vitest": "catalog:",
|
||||
"eslint-plugin-vue": "catalog:",
|
||||
"globals": "catalog:",
|
||||
"jsonc-eslint-parser": "catalog:",
|
||||
"vue-eslint-parser": "catalog:"
|
||||
}
|
||||
}
|
||||
24
internal/lint-configs/eslint-config/src/configs/comments.ts
Normal file
24
internal/lint-configs/eslint-config/src/configs/comments.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { Linter } from 'eslint';
|
||||
|
||||
import { interopDefault } from '../util';
|
||||
|
||||
export async function comments(): Promise<Linter.Config[]> {
|
||||
const [pluginComments] = await Promise.all([
|
||||
// @ts-expect-error - no types
|
||||
interopDefault(import('eslint-plugin-eslint-comments')),
|
||||
] as const);
|
||||
|
||||
return [
|
||||
{
|
||||
plugins: {
|
||||
'eslint-comments': pluginComments,
|
||||
},
|
||||
rules: {
|
||||
'eslint-comments/no-aggregating-enable': 'error',
|
||||
'eslint-comments/no-duplicate-disable': 'error',
|
||||
'eslint-comments/no-unlimited-disable': 'error',
|
||||
'eslint-comments/no-unused-enable': 'error',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
28
internal/lint-configs/eslint-config/src/configs/disableds.ts
Normal file
28
internal/lint-configs/eslint-config/src/configs/disableds.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { Linter } from 'eslint';
|
||||
|
||||
export async function disableds(): Promise<Linter.Config[]> {
|
||||
return [
|
||||
{
|
||||
files: ['**/__tests__/**/*.?([cm])[jt]s?(x)'],
|
||||
name: 'disables/test',
|
||||
rules: {
|
||||
'@typescript-eslint/ban-ts-comment': 'off',
|
||||
'no-console': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.d.ts'],
|
||||
name: 'disables/dts',
|
||||
rules: {
|
||||
'@typescript-eslint/triple-slash-reference': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
|
||||
name: 'disables/js',
|
||||
rules: {
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
25
internal/lint-configs/eslint-config/src/configs/import.ts
Normal file
25
internal/lint-configs/eslint-config/src/configs/import.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { Linter } from 'eslint';
|
||||
|
||||
import * as pluginImport from 'eslint-plugin-import-x';
|
||||
|
||||
export async function importPluginConfig(): Promise<Linter.Config[]> {
|
||||
return [
|
||||
{
|
||||
plugins: {
|
||||
// @ts-expect-error - This is a dynamic import
|
||||
import: pluginImport,
|
||||
},
|
||||
rules: {
|
||||
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
|
||||
'import/first': 'error',
|
||||
'import/newline-after-import': 'error',
|
||||
'import/no-duplicates': 'error',
|
||||
'import/no-mutable-exports': 'error',
|
||||
'import/no-named-default': 'error',
|
||||
'import/no-self-import': 'error',
|
||||
'import/no-unresolved': 'off',
|
||||
'import/no-webpack-loader-syntax': 'error',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
17
internal/lint-configs/eslint-config/src/configs/index.ts
Normal file
17
internal/lint-configs/eslint-config/src/configs/index.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
export * from './command';
|
||||
export * from './comments';
|
||||
export * from './disableds';
|
||||
export * from './ignores';
|
||||
export * from './import';
|
||||
export * from './javascript';
|
||||
export * from './jsdoc';
|
||||
export * from './jsonc';
|
||||
export * from './node';
|
||||
export * from './perfectionist';
|
||||
export * from './prettier';
|
||||
export * from './regexp';
|
||||
export * from './test';
|
||||
export * from './turbo';
|
||||
export * from './typescript';
|
||||
export * from './unicorn';
|
||||
export * from './vue';
|
||||
241
internal/lint-configs/eslint-config/src/configs/javascript.ts
Normal file
241
internal/lint-configs/eslint-config/src/configs/javascript.ts
Normal file
@@ -0,0 +1,241 @@
|
||||
import type { Linter } from 'eslint';
|
||||
|
||||
import js from '@eslint/js';
|
||||
import pluginUnusedImports from 'eslint-plugin-unused-imports';
|
||||
import globals from 'globals';
|
||||
|
||||
export async function javascript(): Promise<Linter.Config[]> {
|
||||
return [
|
||||
{
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.es2021,
|
||||
...globals.node,
|
||||
document: 'readonly',
|
||||
navigator: 'readonly',
|
||||
window: 'readonly',
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
},
|
||||
sourceType: 'module',
|
||||
},
|
||||
linterOptions: {
|
||||
reportUnusedDisableDirectives: true,
|
||||
},
|
||||
plugins: {
|
||||
'unused-imports': pluginUnusedImports,
|
||||
},
|
||||
rules: {
|
||||
...js.configs.recommended.rules,
|
||||
'accessor-pairs': [
|
||||
'error',
|
||||
{ enforceForClassMembers: true, setWithoutGet: true },
|
||||
],
|
||||
'array-callback-return': 'error',
|
||||
'block-scoped-var': 'error',
|
||||
'constructor-super': 'error',
|
||||
'default-case-last': 'error',
|
||||
'dot-notation': ['error', { allowKeywords: true }],
|
||||
eqeqeq: ['error', 'always'],
|
||||
'keyword-spacing': 'off',
|
||||
|
||||
'new-cap': [
|
||||
'error',
|
||||
{ capIsNew: false, newIsCap: true, properties: true },
|
||||
],
|
||||
'no-alert': 'error',
|
||||
'no-array-constructor': 'error',
|
||||
'no-async-promise-executor': 'error',
|
||||
'no-caller': 'error',
|
||||
'no-case-declarations': 'error',
|
||||
'no-class-assign': 'error',
|
||||
'no-compare-neg-zero': 'error',
|
||||
'no-cond-assign': ['error', 'always'],
|
||||
'no-console': ['error', { allow: ['warn', 'error'] }],
|
||||
'no-const-assign': 'error',
|
||||
'no-control-regex': 'error',
|
||||
'no-debugger': 'error',
|
||||
'no-delete-var': 'error',
|
||||
'no-dupe-args': 'error',
|
||||
'no-dupe-class-members': 'error',
|
||||
'no-dupe-keys': 'error',
|
||||
'no-duplicate-case': 'error',
|
||||
'no-empty': ['error', { allowEmptyCatch: true }],
|
||||
'no-empty-character-class': 'error',
|
||||
'no-empty-function': 'off',
|
||||
'no-empty-pattern': 'error',
|
||||
'no-eval': 'error',
|
||||
'no-ex-assign': 'error',
|
||||
'no-extend-native': 'error',
|
||||
'no-extra-bind': 'error',
|
||||
'no-extra-boolean-cast': 'error',
|
||||
'no-fallthrough': 'error',
|
||||
'no-func-assign': 'error',
|
||||
'no-global-assign': 'error',
|
||||
'no-implied-eval': 'error',
|
||||
'no-import-assign': 'error',
|
||||
'no-invalid-regexp': 'error',
|
||||
'no-irregular-whitespace': 'error',
|
||||
'no-iterator': 'error',
|
||||
'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
|
||||
'no-lone-blocks': 'error',
|
||||
'no-loss-of-precision': 'error',
|
||||
'no-misleading-character-class': 'error',
|
||||
'no-multi-str': 'error',
|
||||
'no-new': 'error',
|
||||
'no-new-func': 'error',
|
||||
'no-new-object': 'error',
|
||||
'no-new-symbol': 'error',
|
||||
'no-new-wrappers': 'error',
|
||||
'no-obj-calls': 'error',
|
||||
'no-octal': 'error',
|
||||
'no-octal-escape': 'error',
|
||||
'no-proto': 'error',
|
||||
'no-prototype-builtins': 'error',
|
||||
'no-redeclare': ['error', { builtinGlobals: false }],
|
||||
'no-regex-spaces': 'error',
|
||||
'no-restricted-globals': [
|
||||
'error',
|
||||
{ message: 'Use `globalThis` instead.', name: 'global' },
|
||||
{ message: 'Use `globalThis` instead.', name: 'self' },
|
||||
],
|
||||
'no-restricted-properties': [
|
||||
'error',
|
||||
{
|
||||
message:
|
||||
'Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.',
|
||||
property: '__proto__',
|
||||
},
|
||||
{
|
||||
message: 'Use `Object.defineProperty` instead.',
|
||||
property: '__defineGetter__',
|
||||
},
|
||||
{
|
||||
message: 'Use `Object.defineProperty` instead.',
|
||||
property: '__defineSetter__',
|
||||
},
|
||||
{
|
||||
message: 'Use `Object.getOwnPropertyDescriptor` instead.',
|
||||
property: '__lookupGetter__',
|
||||
},
|
||||
{
|
||||
message: 'Use `Object.getOwnPropertyDescriptor` instead.',
|
||||
property: '__lookupSetter__',
|
||||
},
|
||||
],
|
||||
'no-restricted-syntax': [
|
||||
'error',
|
||||
'DebuggerStatement',
|
||||
'LabeledStatement',
|
||||
'WithStatement',
|
||||
'TSEnumDeclaration[const=true]',
|
||||
'TSExportAssignment',
|
||||
],
|
||||
'no-self-assign': ['error', { props: true }],
|
||||
'no-self-compare': 'error',
|
||||
'no-sequences': 'error',
|
||||
'no-shadow-restricted-names': 'error',
|
||||
'no-sparse-arrays': 'error',
|
||||
'no-template-curly-in-string': 'error',
|
||||
'no-this-before-super': 'error',
|
||||
'no-throw-literal': 'error',
|
||||
'no-undef': 'off',
|
||||
'no-undef-init': 'error',
|
||||
'no-unexpected-multiline': 'error',
|
||||
'no-unmodified-loop-condition': 'error',
|
||||
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
|
||||
'no-unreachable': 'error',
|
||||
'no-unreachable-loop': 'error',
|
||||
'no-unsafe-finally': 'error',
|
||||
'no-unsafe-negation': 'error',
|
||||
'no-unused-expressions': [
|
||||
'error',
|
||||
{
|
||||
allowShortCircuit: true,
|
||||
allowTaggedTemplates: true,
|
||||
allowTernary: true,
|
||||
},
|
||||
],
|
||||
'no-unused-vars': [
|
||||
'error',
|
||||
{
|
||||
args: 'none',
|
||||
caughtErrors: 'none',
|
||||
ignoreRestSiblings: true,
|
||||
vars: 'all',
|
||||
},
|
||||
],
|
||||
'no-use-before-define': [
|
||||
'error',
|
||||
{ classes: false, functions: false, variables: false },
|
||||
],
|
||||
'no-useless-backreference': 'error',
|
||||
'no-useless-call': 'error',
|
||||
'no-useless-catch': 'error',
|
||||
'no-useless-computed-key': 'error',
|
||||
'no-useless-constructor': 'error',
|
||||
'no-useless-rename': 'error',
|
||||
'no-useless-return': 'error',
|
||||
'no-var': 'error',
|
||||
'no-with': 'error',
|
||||
'object-shorthand': [
|
||||
'error',
|
||||
'always',
|
||||
{ avoidQuotes: true, ignoreConstructors: false },
|
||||
],
|
||||
'one-var': ['error', { initialized: 'never' }],
|
||||
'prefer-arrow-callback': [
|
||||
'error',
|
||||
{
|
||||
allowNamedFunctions: false,
|
||||
allowUnboundThis: true,
|
||||
},
|
||||
],
|
||||
'prefer-const': [
|
||||
'error',
|
||||
{
|
||||
destructuring: 'all',
|
||||
ignoreReadBeforeAssign: true,
|
||||
},
|
||||
],
|
||||
'prefer-exponentiation-operator': 'error',
|
||||
|
||||
'prefer-promise-reject-errors': 'error',
|
||||
'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
|
||||
'prefer-rest-params': 'error',
|
||||
'prefer-spread': 'error',
|
||||
'prefer-template': 'error',
|
||||
'space-before-function-paren': 'off',
|
||||
'spaced-comment': 'error',
|
||||
'symbol-description': 'error',
|
||||
'unicode-bom': ['error', 'never'],
|
||||
|
||||
'unused-imports/no-unused-imports': 'error',
|
||||
'unused-imports/no-unused-vars': [
|
||||
'error',
|
||||
{
|
||||
args: 'after-used',
|
||||
argsIgnorePattern: '^_',
|
||||
vars: 'all',
|
||||
varsIgnorePattern: '^_',
|
||||
},
|
||||
],
|
||||
'use-isnan': [
|
||||
'error',
|
||||
{ enforceForIndexOf: true, enforceForSwitchCase: true },
|
||||
],
|
||||
'valid-typeof': ['error', { requireStringLiterals: true }],
|
||||
|
||||
'vars-on-top': 'error',
|
||||
yoda: ['error', 'never'],
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
34
internal/lint-configs/eslint-config/src/configs/jsdoc.ts
Normal file
34
internal/lint-configs/eslint-config/src/configs/jsdoc.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { Linter } from 'eslint';
|
||||
|
||||
import { interopDefault } from '../util';
|
||||
|
||||
export async function jsdoc(): Promise<Linter.Config[]> {
|
||||
const [pluginJsdoc] = await Promise.all([
|
||||
interopDefault(import('eslint-plugin-jsdoc')),
|
||||
] as const);
|
||||
|
||||
return [
|
||||
{
|
||||
plugins: {
|
||||
jsdoc: pluginJsdoc,
|
||||
},
|
||||
rules: {
|
||||
'jsdoc/check-access': 'warn',
|
||||
'jsdoc/check-param-names': 'warn',
|
||||
'jsdoc/check-property-names': 'warn',
|
||||
'jsdoc/check-types': 'warn',
|
||||
'jsdoc/empty-tags': 'warn',
|
||||
'jsdoc/implements-on-classes': 'warn',
|
||||
'jsdoc/no-defaults': 'warn',
|
||||
'jsdoc/no-multi-asterisks': 'warn',
|
||||
'jsdoc/require-param-name': 'warn',
|
||||
'jsdoc/require-property': 'warn',
|
||||
'jsdoc/require-property-description': 'warn',
|
||||
'jsdoc/require-property-name': 'warn',
|
||||
'jsdoc/require-returns-check': 'warn',
|
||||
'jsdoc/require-returns-description': 'warn',
|
||||
'jsdoc/require-yields-check': 'warn',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
258
internal/lint-configs/eslint-config/src/configs/jsonc.ts
Normal file
258
internal/lint-configs/eslint-config/src/configs/jsonc.ts
Normal file
@@ -0,0 +1,258 @@
|
||||
import type { Linter } from 'eslint';
|
||||
|
||||
import { interopDefault } from '../util';
|
||||
|
||||
export async function jsonc(): Promise<Linter.Config[]> {
|
||||
const [pluginJsonc, parserJsonc] = await Promise.all([
|
||||
interopDefault(import('eslint-plugin-jsonc')),
|
||||
interopDefault(import('jsonc-eslint-parser')),
|
||||
] as const);
|
||||
|
||||
return [
|
||||
{
|
||||
files: ['**/*.json', '**/*.json5', '**/*.jsonc', '*.code-workspace'],
|
||||
languageOptions: {
|
||||
parser: parserJsonc as any,
|
||||
},
|
||||
plugins: {
|
||||
jsonc: pluginJsonc as any,
|
||||
},
|
||||
rules: {
|
||||
'jsonc/no-bigint-literals': 'error',
|
||||
'jsonc/no-binary-expression': 'error',
|
||||
'jsonc/no-binary-numeric-literals': 'error',
|
||||
'jsonc/no-dupe-keys': 'error',
|
||||
'jsonc/no-escape-sequence-in-identifier': 'error',
|
||||
'jsonc/no-floating-decimal': 'error',
|
||||
'jsonc/no-hexadecimal-numeric-literals': 'error',
|
||||
'jsonc/no-infinity': 'error',
|
||||
'jsonc/no-multi-str': 'error',
|
||||
'jsonc/no-nan': 'error',
|
||||
'jsonc/no-number-props': 'error',
|
||||
'jsonc/no-numeric-separators': 'error',
|
||||
'jsonc/no-octal': 'error',
|
||||
'jsonc/no-octal-escape': 'error',
|
||||
'jsonc/no-octal-numeric-literals': 'error',
|
||||
'jsonc/no-parenthesized': 'error',
|
||||
'jsonc/no-plus-sign': 'error',
|
||||
'jsonc/no-regexp-literals': 'error',
|
||||
'jsonc/no-sparse-arrays': 'error',
|
||||
'jsonc/no-template-literals': 'error',
|
||||
'jsonc/no-undefined-value': 'error',
|
||||
'jsonc/no-unicode-codepoint-escapes': 'error',
|
||||
'jsonc/no-useless-escape': 'error',
|
||||
'jsonc/space-unary-ops': 'error',
|
||||
'jsonc/valid-json-number': 'error',
|
||||
'jsonc/vue-custom-block/no-parsing-error': 'error',
|
||||
},
|
||||
},
|
||||
sortTsconfig(),
|
||||
sortPackageJson(),
|
||||
];
|
||||
}
|
||||
|
||||
function sortPackageJson(): Linter.Config {
|
||||
return {
|
||||
files: ['**/package.json'],
|
||||
rules: {
|
||||
'jsonc/sort-array-values': [
|
||||
'error',
|
||||
{
|
||||
order: { type: 'asc' },
|
||||
pathPattern: '^files$|^pnpm.neverBuiltDependencies$',
|
||||
},
|
||||
],
|
||||
'jsonc/sort-keys': [
|
||||
'error',
|
||||
{
|
||||
order: [
|
||||
'name',
|
||||
'version',
|
||||
'description',
|
||||
'private',
|
||||
'keywords',
|
||||
'homepage',
|
||||
'bugs',
|
||||
'repository',
|
||||
'license',
|
||||
'author',
|
||||
'contributors',
|
||||
'categories',
|
||||
'funding',
|
||||
'type',
|
||||
'scripts',
|
||||
'files',
|
||||
'sideEffects',
|
||||
'bin',
|
||||
'main',
|
||||
'module',
|
||||
'unpkg',
|
||||
'jsdelivr',
|
||||
'types',
|
||||
'typesVersions',
|
||||
'imports',
|
||||
'exports',
|
||||
'publishConfig',
|
||||
'icon',
|
||||
'activationEvents',
|
||||
'contributes',
|
||||
'peerDependencies',
|
||||
'peerDependenciesMeta',
|
||||
'dependencies',
|
||||
'optionalDependencies',
|
||||
'devDependencies',
|
||||
'engines',
|
||||
'packageManager',
|
||||
'pnpm',
|
||||
'overrides',
|
||||
'resolutions',
|
||||
'husky',
|
||||
'simple-git-hooks',
|
||||
'lint-staged',
|
||||
'eslintConfig',
|
||||
],
|
||||
pathPattern: '^$',
|
||||
},
|
||||
{
|
||||
order: { type: 'asc' },
|
||||
pathPattern: '^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$',
|
||||
},
|
||||
{
|
||||
order: { type: 'asc' },
|
||||
pathPattern: '^(?:resolutions|overrides|pnpm.overrides)$',
|
||||
},
|
||||
{
|
||||
order: ['types', 'import', 'require', 'default'],
|
||||
pathPattern: '^exports.*$',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function sortTsconfig(): Linter.Config {
|
||||
return {
|
||||
files: [
|
||||
'**/tsconfig.json',
|
||||
'**/tsconfig.*.json',
|
||||
'internal/tsconfig/*.json',
|
||||
],
|
||||
rules: {
|
||||
'jsonc/sort-keys': [
|
||||
'error',
|
||||
{
|
||||
order: [
|
||||
'extends',
|
||||
'compilerOptions',
|
||||
'references',
|
||||
'files',
|
||||
'include',
|
||||
'exclude',
|
||||
],
|
||||
pathPattern: '^$',
|
||||
},
|
||||
{
|
||||
order: [
|
||||
/* Projects */
|
||||
'incremental',
|
||||
'composite',
|
||||
'tsBuildInfoFile',
|
||||
'disableSourceOfProjectReferenceRedirect',
|
||||
'disableSolutionSearching',
|
||||
'disableReferencedProjectLoad',
|
||||
/* Language and Environment */
|
||||
'target',
|
||||
'jsx',
|
||||
'jsxFactory',
|
||||
'jsxFragmentFactory',
|
||||
'jsxImportSource',
|
||||
'lib',
|
||||
'moduleDetection',
|
||||
'noLib',
|
||||
'reactNamespace',
|
||||
'useDefineForClassFields',
|
||||
'emitDecoratorMetadata',
|
||||
'experimentalDecorators',
|
||||
/* Modules */
|
||||
'baseUrl',
|
||||
'rootDir',
|
||||
'rootDirs',
|
||||
'customConditions',
|
||||
'module',
|
||||
'moduleResolution',
|
||||
'moduleSuffixes',
|
||||
'noResolve',
|
||||
'paths',
|
||||
'resolveJsonModule',
|
||||
'resolvePackageJsonExports',
|
||||
'resolvePackageJsonImports',
|
||||
'typeRoots',
|
||||
'types',
|
||||
'allowArbitraryExtensions',
|
||||
'allowImportingTsExtensions',
|
||||
'allowUmdGlobalAccess',
|
||||
/* JavaScript Support */
|
||||
'allowJs',
|
||||
'checkJs',
|
||||
'maxNodeModuleJsDepth',
|
||||
/* Type Checking */
|
||||
'strict',
|
||||
'strictBindCallApply',
|
||||
'strictFunctionTypes',
|
||||
'strictNullChecks',
|
||||
'strictPropertyInitialization',
|
||||
'allowUnreachableCode',
|
||||
'allowUnusedLabels',
|
||||
'alwaysStrict',
|
||||
'exactOptionalPropertyTypes',
|
||||
'noFallthroughCasesInSwitch',
|
||||
'noImplicitAny',
|
||||
'noImplicitOverride',
|
||||
'noImplicitReturns',
|
||||
'noImplicitThis',
|
||||
'noPropertyAccessFromIndexSignature',
|
||||
'noUncheckedIndexedAccess',
|
||||
'noUnusedLocals',
|
||||
'noUnusedParameters',
|
||||
'useUnknownInCatchVariables',
|
||||
/* Emit */
|
||||
'declaration',
|
||||
'declarationDir',
|
||||
'declarationMap',
|
||||
'downlevelIteration',
|
||||
'emitBOM',
|
||||
'emitDeclarationOnly',
|
||||
'importHelpers',
|
||||
'importsNotUsedAsValues',
|
||||
'inlineSourceMap',
|
||||
'inlineSources',
|
||||
'mapRoot',
|
||||
'newLine',
|
||||
'noEmit',
|
||||
'noEmitHelpers',
|
||||
'noEmitOnError',
|
||||
'outDir',
|
||||
'outFile',
|
||||
'preserveConstEnums',
|
||||
'preserveValueImports',
|
||||
'removeComments',
|
||||
'sourceMap',
|
||||
'sourceRoot',
|
||||
'stripInternal',
|
||||
/* Interop Constraints */
|
||||
'allowSyntheticDefaultImports',
|
||||
'esModuleInterop',
|
||||
'forceConsistentCasingInFileNames',
|
||||
'isolatedModules',
|
||||
'preserveSymlinks',
|
||||
'verbatimModuleSyntax',
|
||||
/* Completeness */
|
||||
'skipDefaultLibCheck',
|
||||
'skipLibCheck',
|
||||
],
|
||||
pathPattern: '^compilerOptions$',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
19
internal/lint-configs/eslint-config/src/configs/prettier.ts
Normal file
19
internal/lint-configs/eslint-config/src/configs/prettier.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { Linter } from 'eslint';
|
||||
|
||||
import { interopDefault } from '../util';
|
||||
|
||||
export async function prettier(): Promise<Linter.Config[]> {
|
||||
const [pluginPrettier] = await Promise.all([
|
||||
interopDefault(import('eslint-plugin-prettier')),
|
||||
] as const);
|
||||
return [
|
||||
{
|
||||
plugins: {
|
||||
prettier: pluginPrettier,
|
||||
},
|
||||
rules: {
|
||||
'prettier/prettier': 'error',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
20
internal/lint-configs/eslint-config/src/configs/regexp.ts
Normal file
20
internal/lint-configs/eslint-config/src/configs/regexp.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { Linter } from 'eslint';
|
||||
|
||||
import { interopDefault } from '../util';
|
||||
|
||||
export async function regexp(): Promise<Linter.Config[]> {
|
||||
const [pluginRegexp] = await Promise.all([
|
||||
interopDefault(import('eslint-plugin-regexp')),
|
||||
] as const);
|
||||
|
||||
return [
|
||||
{
|
||||
plugins: {
|
||||
regexp: pluginRegexp,
|
||||
},
|
||||
rules: {
|
||||
...pluginRegexp.configs.recommended.rules,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
45
internal/lint-configs/eslint-config/src/configs/test.ts
Normal file
45
internal/lint-configs/eslint-config/src/configs/test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import type { Linter } from 'eslint';
|
||||
|
||||
import { interopDefault } from '../util';
|
||||
|
||||
export async function test(): Promise<Linter.Config[]> {
|
||||
const [pluginTest, pluginNoOnlyTests] = await Promise.all([
|
||||
interopDefault(import('eslint-plugin-vitest')),
|
||||
// @ts-expect-error - no types
|
||||
interopDefault(import('eslint-plugin-no-only-tests')),
|
||||
] as const);
|
||||
|
||||
return [
|
||||
{
|
||||
files: [
|
||||
`**/__tests__/**/*.?([cm])[jt]s?(x)`,
|
||||
`**/*.spec.?([cm])[jt]s?(x)`,
|
||||
`**/*.test.?([cm])[jt]s?(x)`,
|
||||
`**/*.bench.?([cm])[jt]s?(x)`,
|
||||
`**/*.benchmark.?([cm])[jt]s?(x)`,
|
||||
],
|
||||
plugins: {
|
||||
test: {
|
||||
...pluginTest,
|
||||
rules: {
|
||||
...pluginTest.rules,
|
||||
...pluginNoOnlyTests.rules,
|
||||
},
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'no-console': 'off',
|
||||
'node/prefer-global/process': 'off',
|
||||
'test/consistent-test-it': [
|
||||
'error',
|
||||
{ fn: 'it', withinDescribe: 'it' },
|
||||
],
|
||||
'test/no-identical-title': 'error',
|
||||
'test/no-import-node-test': 'error',
|
||||
'test/no-only-tests': 'error',
|
||||
'test/prefer-hooks-in-order': 'error',
|
||||
'test/prefer-lowercase-title': 'error',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
45
internal/lint-configs/eslint-config/src/configs/unicorn.ts
Normal file
45
internal/lint-configs/eslint-config/src/configs/unicorn.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import type { Linter } from 'eslint';
|
||||
|
||||
import { interopDefault } from '../util';
|
||||
|
||||
export async function unicorn(): Promise<Linter.Config[]> {
|
||||
const [pluginUnicorn] = await Promise.all([
|
||||
interopDefault(import('eslint-plugin-unicorn')),
|
||||
] as const);
|
||||
|
||||
return [
|
||||
{
|
||||
plugins: {
|
||||
unicorn: pluginUnicorn,
|
||||
},
|
||||
rules: {
|
||||
...pluginUnicorn.configs.recommended.rules,
|
||||
|
||||
'unicorn/better-regex': 'off',
|
||||
'unicorn/consistent-destructuring': 'off',
|
||||
'unicorn/consistent-function-scoping': 'off',
|
||||
'unicorn/expiring-todo-comments': 'off',
|
||||
'unicorn/filename-case': 'off',
|
||||
'unicorn/import-style': 'off',
|
||||
'unicorn/no-array-for-each': 'off',
|
||||
'unicorn/no-null': 'off',
|
||||
'unicorn/no-useless-undefined': 'off',
|
||||
'unicorn/prefer-at': 'off',
|
||||
'unicorn/prefer-dom-node-text-content': 'off',
|
||||
'unicorn/prefer-export-from': ['error', { ignoreUsedVariables: true }],
|
||||
'unicorn/prefer-global-this': 'off',
|
||||
'unicorn/prefer-top-level-await': 'off',
|
||||
'unicorn/prevent-abbreviations': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: [
|
||||
'scripts/**/*.?([cm])[jt]s?(x)',
|
||||
'internal/**/*.?([cm])[jt]s?(x)',
|
||||
],
|
||||
rules: {
|
||||
'unicorn/no-process-exit': 'off',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
60
internal/lint-configs/eslint-config/src/index.ts
Normal file
60
internal/lint-configs/eslint-config/src/index.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import type { Linter } from 'eslint';
|
||||
|
||||
import {
|
||||
command,
|
||||
comments,
|
||||
disableds,
|
||||
ignores,
|
||||
importPluginConfig,
|
||||
javascript,
|
||||
jsdoc,
|
||||
jsonc,
|
||||
node,
|
||||
perfectionist,
|
||||
prettier,
|
||||
regexp,
|
||||
test,
|
||||
turbo,
|
||||
typescript,
|
||||
unicorn,
|
||||
vue,
|
||||
} from './configs';
|
||||
import { customConfig } from './custom-config';
|
||||
|
||||
type FlatConfig = Linter.Config;
|
||||
|
||||
type FlatConfigPromise =
|
||||
| FlatConfig
|
||||
| FlatConfig[]
|
||||
| Promise<FlatConfig>
|
||||
| Promise<FlatConfig[]>;
|
||||
|
||||
async function defineConfig(config: FlatConfig[] = []) {
|
||||
const configs: FlatConfigPromise[] = [
|
||||
vue(),
|
||||
javascript(),
|
||||
ignores(),
|
||||
prettier(),
|
||||
typescript(),
|
||||
jsonc(),
|
||||
disableds(),
|
||||
importPluginConfig(),
|
||||
node(),
|
||||
perfectionist(),
|
||||
comments(),
|
||||
jsdoc(),
|
||||
unicorn(),
|
||||
test(),
|
||||
regexp(),
|
||||
command(),
|
||||
turbo(),
|
||||
...customConfig,
|
||||
...config,
|
||||
];
|
||||
|
||||
const resolved = await Promise.all(configs);
|
||||
|
||||
return resolved.flat();
|
||||
}
|
||||
|
||||
export { defineConfig };
|
||||
8
internal/lint-configs/eslint-config/src/util.ts
Normal file
8
internal/lint-configs/eslint-config/src/util.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export type Awaitable<T> = Promise<T> | T;
|
||||
|
||||
export async function interopDefault<T>(
|
||||
m: Awaitable<T>,
|
||||
): Promise<T extends { default: infer U } ? U : T> {
|
||||
const resolved = await m;
|
||||
return (resolved as any).default || resolved;
|
||||
}
|
||||
18
internal/lint-configs/prettier-config/index.mjs
Normal file
18
internal/lint-configs/prettier-config/index.mjs
Normal file
@@ -0,0 +1,18 @@
|
||||
export default {
|
||||
endOfLine: 'auto',
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.json5'],
|
||||
options: {
|
||||
quoteProps: 'preserve',
|
||||
singleQuote: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
plugins: ['prettier-plugin-tailwindcss'],
|
||||
printWidth: 80,
|
||||
proseWrap: 'never',
|
||||
semi: true,
|
||||
singleQuote: true,
|
||||
trailingComma: 'all',
|
||||
};
|
||||
28
internal/lint-configs/prettier-config/package.json
Normal file
28
internal/lint-configs/prettier-config/package.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "@vben/prettier-config",
|
||||
"version": "5.0.0",
|
||||
"private": true,
|
||||
"homepage": "https://github.com/vbenjs/vue-vben-admin",
|
||||
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vbenjs/vue-vben-admin.git",
|
||||
"directory": "internal/lint-configs/prettier-config"
|
||||
},
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"main": "./index.mjs",
|
||||
"module": "./index.mjs",
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./index.mjs"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"prettier": "catalog:",
|
||||
"prettier-plugin-tailwindcss": "catalog:"
|
||||
}
|
||||
}
|
||||
141
internal/lint-configs/stylelint-config/index.mjs
Normal file
141
internal/lint-configs/stylelint-config/index.mjs
Normal file
@@ -0,0 +1,141 @@
|
||||
export default {
|
||||
extends: ['stylelint-config-standard', 'stylelint-config-recess-order'],
|
||||
ignoreFiles: [
|
||||
'**/*.js',
|
||||
'**/*.jsx',
|
||||
'**/*.tsx',
|
||||
'**/*.ts',
|
||||
'**/*.json',
|
||||
'**/*.md',
|
||||
],
|
||||
overrides: [
|
||||
{
|
||||
customSyntax: 'postcss-html',
|
||||
files: ['*.(html|vue)', '**/*.(html|vue)'],
|
||||
rules: {
|
||||
'selector-pseudo-class-no-unknown': [
|
||||
true,
|
||||
{
|
||||
ignorePseudoClasses: ['global', 'deep'],
|
||||
},
|
||||
],
|
||||
'selector-pseudo-element-no-unknown': [
|
||||
true,
|
||||
{
|
||||
ignorePseudoElements: ['v-deep', 'v-global', 'v-slotted'],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
customSyntax: 'postcss-scss',
|
||||
extends: [
|
||||
'stylelint-config-recommended-scss',
|
||||
'stylelint-config-recommended-vue/scss',
|
||||
],
|
||||
files: ['*.scss', '**/*.scss'],
|
||||
},
|
||||
],
|
||||
plugins: [
|
||||
'stylelint-order',
|
||||
'@stylistic/stylelint-plugin',
|
||||
'stylelint-prettier',
|
||||
'stylelint-scss',
|
||||
],
|
||||
rules: {
|
||||
'at-rule-no-deprecated': null,
|
||||
'at-rule-no-unknown': [
|
||||
true,
|
||||
{
|
||||
ignoreAtRules: [
|
||||
'extends',
|
||||
'ignores',
|
||||
'include',
|
||||
'mixin',
|
||||
'if',
|
||||
'else',
|
||||
'media',
|
||||
'for',
|
||||
'at-root',
|
||||
'tailwind',
|
||||
'apply',
|
||||
'variants',
|
||||
'responsive',
|
||||
'screen',
|
||||
'function',
|
||||
'each',
|
||||
'use',
|
||||
'forward',
|
||||
'return',
|
||||
],
|
||||
},
|
||||
],
|
||||
'font-family-no-missing-generic-family-keyword': null,
|
||||
'function-no-unknown': null,
|
||||
'import-notation': null,
|
||||
'media-feature-range-notation': null,
|
||||
'named-grid-areas-no-invalid': null,
|
||||
'no-descending-specificity': null,
|
||||
'no-empty-source': null,
|
||||
'order/order': [
|
||||
[
|
||||
'dollar-variables',
|
||||
'custom-properties',
|
||||
'at-rules',
|
||||
'declarations',
|
||||
{
|
||||
name: 'supports',
|
||||
type: 'at-rule',
|
||||
},
|
||||
{
|
||||
name: 'media',
|
||||
type: 'at-rule',
|
||||
},
|
||||
{
|
||||
name: 'include',
|
||||
type: 'at-rule',
|
||||
},
|
||||
'rules',
|
||||
],
|
||||
{ severity: 'error' },
|
||||
],
|
||||
'prettier/prettier': true,
|
||||
'rule-empty-line-before': [
|
||||
'always',
|
||||
{
|
||||
ignore: ['after-comment', 'first-nested'],
|
||||
},
|
||||
],
|
||||
'scss/at-rule-no-unknown': [
|
||||
true,
|
||||
{
|
||||
ignoreAtRules: [
|
||||
'extends',
|
||||
'ignores',
|
||||
'include',
|
||||
'mixin',
|
||||
'if',
|
||||
'else',
|
||||
'media',
|
||||
'for',
|
||||
'at-root',
|
||||
'tailwind',
|
||||
'apply',
|
||||
'variants',
|
||||
'responsive',
|
||||
'screen',
|
||||
'function',
|
||||
'each',
|
||||
'use',
|
||||
'forward',
|
||||
'return',
|
||||
],
|
||||
},
|
||||
],
|
||||
'scss/operator-no-newline-after': null,
|
||||
'selector-class-pattern':
|
||||
'^(?:(?:o|c|u|t|s|is|has|_|js|qa)-)?[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*(?:__[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*)?(?:--[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*)?(?:[.+])?$',
|
||||
|
||||
'selector-not-notation': null,
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user