diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index dbf732f4e889603818dc43e0aaabd7e57a320c4b..0000000000000000000000000000000000000000 --- a/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -node_modules/* -packages/**/node_modules/* -packages/**/dist/* -packages/**/build/* -packages/**/lib/* -packages/**/package/* \ No newline at end of file diff --git a/.husky/commit-msg b/.husky/commit-msg index cc1eedbc61c5125ab2d8b51159ab62a9e28d09c2..813b76ee5e4dc8a69871f668e3bd9dd38554e5a3 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1 @@ -#!/usr/bin/env sh -. "$(dirname "$0")/_/husky.sh" - npx --no-install commitlint --edit diff --git a/.husky/pre-commit b/.husky/pre-commit index 35135873823f9616025422d9bb7026f78a2e2013..80f417e6d9fb269328757afebab2e3abc968c7cf 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1 @@ -#!/usr/bin/env sh -. "$(dirname "$0")/_/husky.sh" - -pnpx @ls-lint/ls-lint && pnpx lint-staged +pnpx @ls-lint/ls-lint && pnpx lint-staged && pnpm dlx eslint diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000000000000000000000000000000000000..6290e9da16383bd9b0b1a121d354af1406aa2a53 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,138 @@ +import globals from "globals"; +import pluginJs from "@eslint/js"; +import tseslint from "typescript-eslint"; +import pluginVue from "eslint-plugin-vue"; +import farrislint from "@farris/eslint-config"; + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + { files: ["**/*.{js,mjs,cjs,ts,vue}"] }, + { languageOptions: { globals: globals.browser } }, + pluginJs.configs.recommended, + ...tseslint.configs.recommended, + ...pluginVue.configs["flat/essential"], + { files: ["**/*.vue"], languageOptions: { parserOptions: { parser: tseslint.parser } } }, + { + ignores: [ + "node_modules/*", + "packages/**/node_modules/*", + "packages/**/dist/*", + "packages/**/build/*", + "packages/**/lib/*", + "packages/**/package/*", + "packages/ui-vue/docs/*", + "packages/ui-vue/demos/*", + "packages/farris-theme/*", + "packages/f-theme-editor-project/*", + "packages/mobile-ui-vue/docs/*", + ] + }, + { + rules: { + 'accessor-pairs': 'off', + 'array-callback-return': 'off', + 'arrow-body-style': 'off', + curly: 'error', + 'class-methods-use-this': 'off', + complexity: [ + 'error', + { + max: 40 + } + ], + 'consistent-return': 'off', + 'default-case': 'off', + 'eol-last': 'warn', + eqeqeq: ['error', 'smart'], + 'func-names': 'off', + 'import/order': 'off', + 'import/extensions': 'off', + 'import/no-unresolved': 'off', + 'import/prefer-default-export': 'off', + 'import/no-extraneous-dependencies': 'off', + indent: 0, + 'max-depth': 'off', + 'max-len': 'off', + 'max-nested-callbacks': ['error', 6], + 'max-params': 'off', + 'no-new': 'off', + 'no-bitwise': 'off', + 'no-console': [ + 'error', + { + allow: [ + 'log', + 'warn', + 'dir', + 'timeLog', + 'assert', + 'clear', + 'count', + 'countReset', + 'group', + 'groupEnd', + 'table', + 'dirxml', + 'error', + 'groupCollapsed', + 'Console', + 'profile', + 'profileEnd', + 'timeStamp', + 'context' + ] + } + ], + 'no-multiple-empty-lines': 'error', + 'no-restricted-globals': 'off', + 'no-shadow': 'off', + 'no-trailing-spaces': 'off', + 'no-param-reassign': 'off', + 'no-plusplus': 'off', + 'no-nested-ternary': 'off', + 'no-undef': 'off', + 'no-underscore-dangle': 'off', + 'no-unused-expressions': 'off', + 'no-unused-labels': 'error', + 'no-use-before-define': 'error', + 'no-useless-constructor': 'off', + 'no-useless-concat': 'off', + 'no-var': 'error', + 'prefer-const': 'error', + 'prefer-destructuring': ['error', { object: true, array: false }], + 'prefer-promise-reject-errors': 'off', + 'prefer-template': 'off', + 'space-in-parens': ['error', 'never'], + 'spaced-comment': ['error', 'always'], + '@typescript-eslint/camelcase': 'off', + '@typescript-eslint/ban-ts-comment': 'off', + '@typescript-eslint/no-unused-expressions': 'off', + '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/no-var-requires': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-empty-function': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-useless-constructor': 'off', + '@typescript-eslint/no-parameter-properties': 'off', + '@typescript-eslint/no-require-imports': 'off', + '@typescript-eslint/dot-notation': 'off', + '@typescript-eslint/no-misused-new': 'error', + '@typescript-eslint/prefer-function-type': 'error', + '@/semi': ['warn', 'always'], + '@typescript-eslint/unified-signatures': 'error', + '@typescript-eslint/no-shadow': 'off', + '@typescript-eslint/member-ordering': 'off', + '@typescript-eslint/no-this-alias': 'off', + 'vue/no-v-html': 'off', + 'vue/attributes-order': 'off', + 'vue/require-v-for-key': 'off', + 'vue/require-default-prop': 'off', + 'vue/no-unused-components': 'off', + 'vue/multi-word-component-names': 'off', + 'vue/return-in-computed-property': 'off' + } + }, + { plugins: { farrislint }, rules: { "prefer-object-spread": "off" } } +]; diff --git a/package.json b/package.json index 9e387f555fa3ef3a356b32d8b1ce27720b491b57..42db7dac64523ade03db4334f069516876f00b7c 100644 --- a/package.json +++ b/package.json @@ -64,9 +64,9 @@ "date-fns": "^3.6.0", "del-cli": "^5.1.0", "esbuild-register": "^3.3.0", - "eslint": "^8.56.0", + "eslint": "^8.57.1", "eslint-plugin-import": "^2.26.0", - "eslint-plugin-vue": "^9.4.0", + "eslint-plugin-vue": "^9.29.1", "express": "^4.16.3", "fs-extra": "^11.2.0", "happy-dom": "^14.12.0", @@ -109,11 +109,14 @@ "packages/ui-vue/{*.scss,*.css}": "stylelint --fix" }, "dependencies": { + "@eslint/js": "^9.17.0", "axios": "^1.7.2", "echarts": "^5.5.0", + "globals": "^15.13.0", "jsonp": "^0.2.1", "markdown-it": "^14.1.0", "markdown-it-container": "^4.0.0", - "ts-jest": "^29.1.2" + "ts-jest": "^29.1.2", + "typescript-eslint": "^8.18.0" } } \ No newline at end of file diff --git a/packages/bef/scripts/commands/build-vite-config.cjs b/packages/bef/scripts/commands/build-vite-config.cjs index 6eee5f9af6320fae4e228e42619166f61cb1ecda..ceacb74bb19e3559968afad51038d4e455b803f8 100644 --- a/packages/bef/scripts/commands/build-vite-config.cjs +++ b/packages/bef/scripts/commands/build-vite-config.cjs @@ -39,5 +39,5 @@ module.exports = function (options) { }, }, }, - }) -} \ No newline at end of file + }); +}; diff --git a/packages/bef/src/views/dynamic-demo/module/index.ts b/packages/bef/src/views/dynamic-demo/module/index.ts index 46266fdaf84b9a1f382e735185e8397d98e49bad..03570d1048707fb3afcb051017f0d0b564344cbd 100644 --- a/packages/bef/src/views/dynamic-demo/module/index.ts +++ b/packages/bef/src/views/dynamic-demo/module/index.ts @@ -1,2 +1,2 @@ export * from './dynamic-repository'; -export * from './dynamic-module'; \ No newline at end of file +export * from './dynamic-module'; diff --git a/packages/bef/src/views/dynamic-demo/module/services/base-data.service.ts b/packages/bef/src/views/dynamic-demo/module/services/base-data.service.ts index e3787ba69613b655b916fb299224af69c26f503b..6f0d789dcff6fbecea4def488a3113c3dceba156 100644 --- a/packages/bef/src/views/dynamic-demo/module/services/base-data.service.ts +++ b/packages/bef/src/views/dynamic-demo/module/services/base-data.service.ts @@ -45,4 +45,4 @@ class BaseDataService { } } -export { BaseDataService } \ No newline at end of file +export { BaseDataService }; diff --git a/packages/bef/src/views/static-demo/module/static-entity-store.ts b/packages/bef/src/views/static-demo/module/static-entity-store.ts index ed59ef34c6fd886f2491daac927c26d39f545e16..6eab1d0bf0f4810cf412f9c77f09149b2074f072 100644 --- a/packages/bef/src/views/static-demo/module/static-entity-store.ts +++ b/packages/bef/src/views/static-demo/module/static-entity-store.ts @@ -1,4 +1,4 @@ -// eslint-disable-next-line max-classes-per-file + import { FdEntityStore, FdField, EntityState, EntityStore, Entity } from '@farris/devkit-vue'; class StaticEntity extends Entity { diff --git a/packages/bef/src/views/static-demo/module/static-repository.ts b/packages/bef/src/views/static-demo/module/static-repository.ts index a6ea87138abb912f56327f892d9f846f0f38e9f8..754e60f51f7ff4eebe7e0326d5ca7b4dac7de1d2 100644 --- a/packages/bef/src/views/static-demo/module/static-repository.ts +++ b/packages/bef/src/views/static-demo/module/static-repository.ts @@ -1,4 +1,4 @@ -/* eslint-disable max-classes-per-file */ + import { FdRepository, Module } from '@farris/devkit-vue'; import { BefProxy, BefRepository } from '../../../../lib/index'; import { StaticEntity } from './static-entity-store'; diff --git a/packages/bef/src/views/static-demo/module/static-ui-store.ts b/packages/bef/src/views/static-demo/module/static-ui-store.ts index b3d9245e0e42427e80ba7ef06d4512ee358a9566..35caaaecd7d8a5bf86d4e06446f89e00b2d59e38 100644 --- a/packages/bef/src/views/static-demo/module/static-ui-store.ts +++ b/packages/bef/src/views/static-demo/module/static-ui-store.ts @@ -1,4 +1,4 @@ -/* eslint-disable max-classes-per-file */ + import { FdUIStore, FdUIState, UIState, UIStore } from '@farris/devkit-vue'; class StaticUIState extends UIState { diff --git a/packages/bef/src/views/static-demo/module/static-viewmodel.ts b/packages/bef/src/views/static-demo/module/static-viewmodel.ts index d579e516d070f45f786f0f2038769ab257fd1463..315d2519b783987e5665f86cb3f610b90e52a83a 100644 --- a/packages/bef/src/views/static-demo/module/static-viewmodel.ts +++ b/packages/bef/src/views/static-demo/module/static-viewmodel.ts @@ -1,4 +1,4 @@ -/* eslint-disable max-classes-per-file */ + import { Injector, FdViewModel, FdGetter, FdAction, FdCommandAction, ViewModelState, ViewModel } from '@farris/devkit-vue'; import { serviceProviders } from './services/index'; import { LoadHandler, SaveHandler, TestHandler } from './handlers/index'; @@ -55,4 +55,4 @@ class StaticViewModel extends ViewModel { public test() {}; } -export { StaticViewModelState, StaticViewModel }; \ No newline at end of file +export { StaticViewModelState, StaticViewModel }; diff --git a/packages/cli/bin/index.js b/packages/cli/bin/index.js old mode 100644 new mode 100755 diff --git a/packages/cli/templates/mobile/.eslintrc.cjs b/packages/cli/templates/mobile/.eslintrc.cjs index 6f40582dda70241afd3bbd38da6853278bef4aaf..12d29bc148b81fde03745867c2cd6d66b0d57dfd 100644 --- a/packages/cli/templates/mobile/.eslintrc.cjs +++ b/packages/cli/templates/mobile/.eslintrc.cjs @@ -1,5 +1,5 @@ /* eslint-env node */ -require('@rushstack/eslint-patch/modern-module-resolution') +require('@rushstack/eslint-patch/modern-module-resolution'); module.exports = { root: true, @@ -12,4 +12,4 @@ module.exports = { parserOptions: { ecmaVersion: 'latest' } -} +}; diff --git a/packages/cli/templates/mobile/farris.config.mjs b/packages/cli/templates/mobile/farris.config.mjs index 127024b2df4b30d24ebaeddbc811ac92f7cff552..4498683cbe8ba8279c25e5b8641a716dc636e42b 100644 --- a/packages/cli/templates/mobile/farris.config.mjs +++ b/packages/cli/templates/mobile/farris.config.mjs @@ -21,4 +21,4 @@ export default { // plugins: [], // viteConfig 配置项 viteConfig: {} -} \ No newline at end of file +}; diff --git a/packages/cli/templates/mobile/src/App.vue b/packages/cli/templates/mobile/src/App.vue index eaca40e6c0940d9bd980b2f01c2f5989deb30f9b..9dc0b8681889174d2364a0777b3d046e7f369415 100644 --- a/packages/cli/templates/mobile/src/App.vue +++ b/packages/cli/templates/mobile/src/App.vue @@ -1,5 +1,5 @@