From fda18c4734417cf18fc5fb403daf9eb8289ecc43 Mon Sep 17 00:00:00 2001 From: feng Date: Mon, 2 May 2022 18:58:09 +0800 Subject: [PATCH 1/3] tools: refactor lint-sh.js to esm module --- .github/workflows/linters.yml | 2 +- tools/{lint-sh.js => lint-sh.mjs} | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) rename tools/{lint-sh.js => lint-sh.mjs} (93%) diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 7373aabaca0456..79e4696d048375 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -156,7 +156,7 @@ jobs: persist-credentials: false - run: shellcheck -V - name: Lint Shell scripts - run: tools/lint-sh.js . + run: tools/lint-sh.mjs . lint-codeowners: if: github.event.pull_request.draft == false runs-on: ubuntu-latest diff --git a/tools/lint-sh.js b/tools/lint-sh.mjs similarity index 93% rename from tools/lint-sh.js rename to tools/lint-sh.mjs index 378cb38af28744..d7e6e1406bd645 100755 --- a/tools/lint-sh.js +++ b/tools/lint-sh.mjs @@ -1,9 +1,9 @@ #!/usr/bin/env node -'use strict'; -const { execSync, spawn } = require('child_process'); -const { promises: fs, readdirSync, statSync } = require('fs'); -const { extname, join, relative, resolve } = require('path'); +import { execSync, spawn } from 'child_process'; +import { promises as fs, readdirSync, statSync } from 'fs'; +import { extname, join, relative, resolve } from 'path'; +import process from 'process'; const FIX_MODE_ENABLED = process.argv.includes('--fix'); const USE_NPX = process.argv.includes('--from-npx'); @@ -178,7 +178,11 @@ if ( SPAWN_OPTIONS.cwd = process.cwd(); checkFiles(entryPoint).catch(onError); } else { - onError(new Error('You must provide a valid directory or file path. ' + - `Received '${process.argv[2]}'.`)); + onError( + new Error( + 'You must provide a valid directory or file path. ' + + `Received '${process.argv[2]}'.` + ) + ); } } From 783516af97a7e90a6f794685afb48855f7d32c4a Mon Sep 17 00:00:00 2001 From: Feng Yu Date: Tue, 3 May 2022 21:07:28 +0800 Subject: [PATCH 2/3] Update tools/lint-sh.mjs Co-authored-by: Antoine du Hamel --- tools/lint-sh.mjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/lint-sh.mjs b/tools/lint-sh.mjs index d7e6e1406bd645..0d0e6cffe8b0e2 100755 --- a/tools/lint-sh.mjs +++ b/tools/lint-sh.mjs @@ -1,9 +1,9 @@ #!/usr/bin/env node -import { execSync, spawn } from 'child_process'; -import { promises as fs, readdirSync, statSync } from 'fs'; -import { extname, join, relative, resolve } from 'path'; -import process from 'process'; +import { execSync, spawn } from 'node:child_process'; +import { promises as fs, readdirSync, statSync } from 'node:fs'; +import { extname, join, relative, resolve } from 'node:path'; +import process from 'node:process'; const FIX_MODE_ENABLED = process.argv.includes('--fix'); const USE_NPX = process.argv.includes('--from-npx'); From 00ed30944d5f997bbdbcfe4b67b578916b6fda8d Mon Sep 17 00:00:00 2001 From: feng Date: Tue, 3 May 2022 22:44:18 +0800 Subject: [PATCH 3/3] revert unrelated change --- tools/lint-sh.mjs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tools/lint-sh.mjs b/tools/lint-sh.mjs index 0d0e6cffe8b0e2..681c7cd5665dce 100755 --- a/tools/lint-sh.mjs +++ b/tools/lint-sh.mjs @@ -178,11 +178,7 @@ if ( SPAWN_OPTIONS.cwd = process.cwd(); checkFiles(entryPoint).catch(onError); } else { - onError( - new Error( - 'You must provide a valid directory or file path. ' + - `Received '${process.argv[2]}'.` - ) - ); + onError(new Error('You must provide a valid directory or file path. ' + + `Received '${process.argv[2]}'.`)); } }