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: fix lint (#1242)

白熱c7606dbf90c5
diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml
new file mode 100644
index 0000000000..49c9fcaa22
--- /dev/null
+++ b/.github/actions/setup-node/action.yml
@@ -0,0 +1,21 @@
+name: Node Setup
+description: Node.js setup for CI, including cache configuration
+
+runs:
+ using: composite
+ steps:
+ - name: Setup pnpm
+ uses: pnpm/action-setup@v2
+ with:
+ version: 8
+ run_install: false
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: 20
+ cache: pnpm
+
+ - name: Install dependencies
+ run: pnpm install
+ shell: bash
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e2eba381b7..3bcb01771d 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -22,32 +22,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 18
-
- - name: Install pnpm
- uses: pnpm/action-setup@v2
- with:
- version: 8
- run_install: false
-
- - name: Get pnpm store directory
- shell: bash
- run: |
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
-
- - name: Setup pnpm cache
- uses: actions/cache@v3
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pnpm-
-
- - name: Install dependencies
- run: pnpm install
+ - name: Setup Node.js
+ uses: ./.github/actions/setup-node
- name: 📦 Build
run: pnpm run build
diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml
index 725dea65cd..ee055dbde7 100644
--- a/.github/workflows/ci-lint.yml
+++ b/.github/workflows/ci-lint.yml
@@ -21,41 +21,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 18
-
- - name: Install pnpm
- uses: pnpm/action-setup@v2
- with:
- version: 8
- run_install: false
-
- - name: Get pnpm store directory
- shell: bash
- run: |
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
-
- - name: Setup pnpm cache
- uses: actions/cache@v3
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pnpm-store-
-
- - name: Setup ESLint cache
- uses: actions/cache@v3
- with:
- path: .eslintcache
- key: |
- ${{ runner.os }}-eslint-${{ hashFiles('.eslintrc.cjs') }}
- restore-keys: |
- ${{ runner.os }}-eslint-
-
- - name: Install dependencies
- run: pnpm install
+ - name: Setup Node.js
+ uses: ./.github/actions/setup-node
- name: 🌡️ Run ESLint
run: pnpm run lint
@@ -71,32 +38,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 18
-
- - name: Install pnpm
- uses: pnpm/action-setup@v2
- with:
- version: 8
- run_install: false
-
- - name: Get pnpm store directory
- shell: bash
- run: |
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
-
- - name: Setup pnpm cache
- uses: actions/cache@v3
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pnpm-store-
-
- - name: Install dependencies
- run: pnpm install
+ - name: Setup Node.js
+ uses: ./.github/actions/setup-node
- name: 🧼 Type checking
run: npm run lint:types
@@ -112,32 +55,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 18
-
- - name: Install pnpm
- uses: pnpm/action-setup@v2
- with:
- version: 8
- run_install: false
-
- - name: Get pnpm store directory
- shell: bash
- run: |
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
-
- - name: Setup pnpm cache
- uses: actions/cache@v3
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pnpm-store-
-
- - name: Install dependencies
- run: pnpm install
+ - name: Setup Node.js
+ uses: ./.github/actions/setup-node
- name: 🎨 Run Stylelint
run: pnpm run lint:style
diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml
index 4e8764cf2f..0a85d3309b 100644
--- a/.github/workflows/ci-test.yml
+++ b/.github/workflows/ci-test.yml
@@ -18,32 +18,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 18
-
- - name: Install pnpm
- uses: pnpm/action-setup@v2
- with:
- version: 8
- run_install: false
-
- - name: Get pnpm store directory
- shell: bash
- run: |
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
-
- - name: Setup pnpm cache
- uses: actions/cache@v3
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pnpm-store-
-
- - name: Install dependencies
- run: pnpm install
+ - name: Setup Node.js
+ uses: ./.github/actions/setup-node
- name: 🩺 Run test
run: pnpm run coverage
diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml
index b974a84086..d022294094 100644
--- a/.github/workflows/playwright.yml
+++ b/.github/workflows/playwright.yml
@@ -14,12 +14,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- - uses: actions/setup-node@v3
- with:
- node-version: 18
-
- - name: Install dependencies
- run: npm install -g pnpm && pnpm install
+ - name: Setup Node.js
+ uses: ./.github/actions/setup-node
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/preview-deploy.yml
index b058bfb4c2..495722075a 100644
--- a/.github/workflows/preview-deploy.yml
+++ b/.github/workflows/preview-deploy.yml
@@ -89,32 +89,8 @@ jobs:
with:
ref: ${{ needs.setup.outputs.ref }}
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 18
-
- - name: Install pnpm
- uses: pnpm/action-setup@v2
- with:
- version: 8
- run_install: false
-
- - name: Get pnpm store directory
- shell: bash
- run: |
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
-
- - name: Setup pnpm cache
- uses: actions/cache@v3
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pnpm-
-
- - name: Install dependencies
- run: pnpm install
+ - name: Setup Node.js
+ uses: ./.github/actions/setup-node
# ================= Deploy Demo =================
- name: 📦 Build demo
@@ -157,32 +133,8 @@ jobs:
with:
ref: ${{ needs.setup.outputs.ref }}
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 18
-
- - name: Install pnpm
- uses: pnpm/action-setup@v2
- with:
- version: 8
- run_install: false
-
- - name: Get pnpm store directory
- shell: bash
- run: |
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
-
- - name: Setup pnpm cache
- uses: actions/cache@v3
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pnpm-
-
- - name: Install dependencies
- run: pnpm install
+ - name: Setup Node.js
+ uses: ./.github/actions/setup-node
# ================= Deploy Storybook =================
- name: 📦 Build storybook
diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml
index 17b7f4dce5..f002d5cd6a 100644
--- a/.github/workflows/release-nightly.yml
+++ b/.github/workflows/release-nightly.yml
@@ -55,30 +55,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 18
- registry-url: ${{ secrets.VERDACCIO_URL }}
-
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- - name: Get pnpm store directory
- shell: bash
- run: |
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
-
- - name: Setup pnpm cache
- uses: actions/cache@v3
+ - name: Install Node.js
+ uses: actions/setup-node@v3
with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pnpm-
+ node-version: 18
+ registry-url: ${{ secrets.VERDACCIO_URL }}
+ cache: pnpm
- name: 📌 Get package version (version + date)
id: nightly-version
@@ -87,18 +75,6 @@ jobs:
version_number=$(echo "$original_version" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*$/\1/')
echo "version=$version_number-nightly.$(date +%Y%m%d%H%M)" >> $GITHUB_OUTPUT
- # - name: Create tag
- # uses: actions/github-script@v5
- # with:
- # github-token: ${{ secrets.GITHUB_TOKEN }}
- # script: |
- # github.rest.git.createRef({
- # owner: context.repo.owner,
- # repo: context.repo.repo,
- # ref: 'refs/tags/${{ steps.nightly-version.outputs.version }}',
- # sha: context.sha
- # })
-
- name: 🔏 Set all monorepo's package version
run: |
for package in $(ls packages); do
@@ -127,32 +103,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 18
-
- - name: Install pnpm
- uses: pnpm/action-setup@v2
- with:
- version: 8
- run_install: false
-
- - name: Get pnpm store directory
- shell: bash
- run: |
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
-
- - name: Setup pnpm cache
- uses: actions/cache@v3
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pnpm-
-
- - name: Install dependencies
- run: pnpm install
+ - name: Setup Node.js
+ uses: ./.github/actions/setup-node
# ================= Deploy Demo =================
- name: 📦 Build demo
@@ -182,32 +134,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 18
-
- - name: Install pnpm
- uses: pnpm/action-setup@v2
- with:
- version: 8
- run_install: false
-
- - name: Get pnpm store directory
- shell: bash
- run: |
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
-
- - name: Setup pnpm cache
- uses: actions/cache@v3
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pnpm-
-
- - name: Install dependencies
- run: pnpm install
+ - name: Setup Node.js
+ uses: ./.github/actions/setup-node
# ================= Deploy Storybook =================
- name: 📦 Build storybook
diff --git a/.github/workflows/release-unstable.yml b/.github/workflows/release-unstable.yml
index 0f48a98795..9172584a6e 100644
--- a/.github/workflows/release-unstable.yml
+++ b/.github/workflows/release-unstable.yml
@@ -22,30 +22,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 18
- registry-url: https://registry.npmjs.org
-
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- - name: Get pnpm store directory
- shell: bash
- run: |
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
-
- - name: Setup pnpm cache
- uses: actions/cache@v3
+ - name: Install Node.js
+ uses: actions/setup-node@v3
with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pnpm-
+ node-version: 18
+ registry-url: https://registry.npmjs.org
- name: 🚚 Get release type
id: release-type
@@ -84,32 +71,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 18
-
- - name: Install pnpm
- uses: pnpm/action-setup@v2
- with:
- version: 8
- run_install: false
-
- - name: Get pnpm store directory
- shell: bash
- run: |
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
-
- - name: Setup pnpm cache
- uses: actions/cache@v3
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pnpm-
-
- - name: Install dependencies
- run: pnpm install
+ - name: Setup Node.js
+ uses: ./.github/actions/setup-node
# ================= Deploy Demo =================
- name: 📦 Build demo
@@ -139,32 +102,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- - name: Install Node.js
- uses: actions/setup-node@v3
- with:
- node-version: 18
-
- - name: Install pnpm
- uses: pnpm/action-setup@v2
- with:
- version: 8
- run_install: false
-
- - name: Get pnpm store directory
- shell: bash
- run: |
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
-
- - name: Setup pnpm cache
- uses: actions/cache@v3
- with:
- path: ${{ env.STORE_PATH }}
- key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- restore-keys: |
- ${{ runner.os }}-pnpm-
-
- - name: Install dependencies
- run: pnpm install
+ - name: Setup Node.js
+ uses: ./.github/actions/setup-node
# ================= Deploy Storybook =================
- name: 📦 Build storybook
diff --git a/eslint.config.js b/eslint.config.js
index c3be2ba86f..3b0b995cfa 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -15,6 +15,7 @@ export default antfu({
},
markdown: false,
rules: {
+ curly: ['error', 'multi-line'],
'import/no-cycle': 'error',
'ts/no-explicit-any': 'warn',
'style/brace-style': ['warn', '1tbs', { allowSingleLine: true }],
@@ -27,7 +28,7 @@ export default antfu({
functions: 'never',
}],
'style/arrow-parens': ['error', 'always'],
- curly: ['error', 'multi-line'],
+ 'ts/no-redeclare': 'off',
'antfu/if-newline': 'off',
'style/spaced-comment': 'off',
'tunicorn/number-literal-case': 'off',
@@ -80,7 +81,6 @@ export default antfu({
'antfu/consistent-list-newline': 'off',
'ts/no-use-before-define': 'warn',
'intunicorn/number-literal-case': 'off',
- 'ts/no-redeclare': 'warn',
'test/no-identical-title': 'warn',
'ts/no-non-null-asserted-optional-chain': 'warn',
'no-restricted-syntax': 'warn',
diff --git a/packages/engine-formula/src/engine/utils/reference.ts b/packages/engine-formula/src/engine/utils/reference.ts
index fc8ef22448..9fecb1f613 100644
--- a/packages/engine-formula/src/engine/utils/reference.ts
+++ b/packages/engine-formula/src/engine/utils/reference.ts
@@ -192,7 +192,7 @@ export function serializeRangeToRefString(gridRangeName: IGridRangeName) {
}
function singleReferenceToGrid(refBody: string) {
- const row = parseInt(refBody.replace($ROW_REGEX, '')) - 1;
+ const row = Number.parseInt(refBody.replace($ROW_REGEX, '')) - 1;
const column = Tools.ABCatNum(refBody.replace($COLUMN_REGEX, ''));
const absoluteRefType = getAbsoluteRefTypeWithSingleString(refBody);
@@ -299,19 +299,16 @@ export function deserializeRangeWithSheet(refString: string): IGridRangeName {
/**
* Determine whether the sheet name needs to be wrapped in quotes
-
- Excel will quote the worksheet name if any of the following is true:
-
- - It contains any space or punctuation characters, such as ()$,;-{}"'()【】“”‘’%… and many more
- - It is a valid cell reference in A1 notation, e.g. B1048576 is quoted, B1048577 is not
- - It is a valid cell reference in R1C1 notation, e.g. RC, RC2, R5C, R-4C, RC-8, R, C
- - It starts with a non-letter, e.g. 99, 1.5, 12a, 💩a
- - Excel will not quote worksheet names if they only contain non-punctuation, non-letter characters in non-initial positions. For example, a💩 remains unquoted.
-
- In addition, if a worksheet name contains single quotes, these will be doubled up within the name itself. For example, the sheet name a'b'c becomes 'a''b''c'.
+ * Excel will quote the worksheet name if any of the following is true:
+ * - It contains any space or punctuation characters, such as ()$,;-{}"'()【】“”‘’%… and many more
+ * - It is a valid cell reference in A1 notation, e.g. B1048576 is quoted, B1048577 is not
+ * - It is a valid cell reference in R1C1 notation, e.g. RC, RC2, R5C, R-4C, RC-8, R, C
+ * - It starts with a non-letter, e.g. 99, 1.5, 12a, 💩a
+ * - Excel will not quote worksheet names if they only contain non-punctuation, non-letter characters in non-initial positions. For example, a💩 remains unquoted.*
+ * In addition, if a worksheet name contains single quotes, these will be doubled up within the name itself. For example, the sheet name a'b'c becomes 'a''b''c'.
*
* reference https://stackoverflow.com/questions/41677779/when-does-excel-surround-sheet-names-with-single-quotes-in-workbook-xml-or-othe
- *
+ *
* @param name Sheet name
* @returns Result
*/
@@ -336,7 +333,6 @@ export function needsQuoting(name: string) {
// Check for spaces, punctuation and special characters
- // eslint-disable-next-line no-misleading-character-class, no-useless-escape
if (/[\s!$%^&*()+\-=\[\]{};':"\\|,.<>\/?]/.test(name)) {
return true;
}
@@ -346,7 +342,7 @@ export function needsQuoting(name: string) {
function isA1Notation(name: string) {
const match = name.match(/[1-9][0-9]{0,6}/);
- return /^[A-Z]+[1-9][0-9]{0,6}$/.test(name) && match !== null && parseInt(match[0], 10) <= 1048576;
+ return /^[A-Z]+[1-9][0-9]{0,6}$/.test(name) && match !== null && Number.parseInt(match[0], 10) <= 1048576;
}
function isR1C1Notation(name: string) {