Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

chore(lint): add import sorting rules & magic number warnings (#93)

白熱781389fcdbd4
diff --git a/.eslintrc.js b/.eslintrc.js
index a8070d32bc..2fc33d460e 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -5,7 +5,7 @@ module.exports = {
es2021: true,
},
parser: '@typescript-eslint/parser',
- plugins: ['@typescript-eslint', 'prettier', 'import', 'import-newlines', 'unused-imports'],
+ plugins: ['@typescript-eslint', 'prettier', 'import', 'import-newlines', 'unused-imports', 'simple-import-sort'],
extends: [
'airbnb-base', // https://www.npmjs.com/package/eslint-config-airbnb-base
'airbnb-typescript/base', // https://www.npmjs.com/package/eslint-config-airbnb-typescript
@@ -104,6 +104,9 @@ module.exports = {
'no-unsafe-optional-chaining': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/no-redeclare': 'off', // dependency interface and dependency token share the same name
+ 'no-magic-numbers': ['warn'],
+ 'simple-import-sort/imports': 'error',
+ 'simple-import-sort/exports': 'error',
},
// https://www.npmjs.com/package/eslint-import-resolver-typescript
settings: {
diff --git a/package.json b/package.json
index da358b4765..9999001773 100644
--- a/package.json
+++ b/package.json
@@ -62,6 +62,7 @@
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-plugin-import-newlines": "^1.3.0",
"eslint-plugin-prettier": "^4.2.1",
+ "eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"execa": "^4.1.0",
"find-process": "^1.4.7",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a1db1e9dd3..712fcaeb46 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -78,6 +78,9 @@ importers:
eslint-plugin-prettier:
specifier: ^4.2.1
+ eslint-plugin-simple-import-sort:
+ specifier: ^10.0.0
+ version: 10.0.0([email protected])
eslint-plugin-unused-imports:
specifier: ^2.0.0
version: 2.0.0(@typescript-eslint/[email protected])([email protected])
@@ -6119,6 +6122,14 @@ packages:
prettier-linter-helpers: 1.0.0
dev: true
+ resolution: {integrity: sha512-AeTvO9UCMSNzIHRkg8S6c3RPy5YEwKWSQPx3DYghLedo2ZQxowPFLGDN1AZ2evfg6r6mjBSZSLxLFsWSu3acsw==}
+ peerDependencies:
+ eslint: '>=5.0.0'
+ dependencies:
+ eslint: 8.35.0
+ dev: true
+
resolution: {integrity: sha512-3APeS/tQlTrFa167ThtP0Zm0vctjr4M44HMpeg1P4bK6wItarumq0Ma82xorMKdFsWpphQBlRPzw/pxiVELX1A==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}