From c4c1a0d45a568b352853a49d222d4cfbdeba349a Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Sun, 13 Oct 2024 14:11:25 +0200 Subject: [PATCH] Migrate to neostandard --- .github/workflows/eslint.yml | 26 ++++++++++++++++++++++++++ .github/workflows/rubocop.yml | 2 +- Rakefile | 7 ++++++- eslint.config.mjs | 13 +++++++++++++ package.json | 7 ++++--- test/javascript/run-qunit.mjs | 4 +++- 6 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/eslint.yml create mode 100644 eslint.config.mjs diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml new file mode 100644 index 0000000..deffd73 --- /dev/null +++ b/.github/workflows/eslint.yml @@ -0,0 +1,26 @@ +name: ESLint + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +permissions: + contents: read + +jobs: + eslint: + name: ESLint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: '18' + - name: Install node dependencies + run: pnpm install + - name: Run JavaScript linter + run: pnpm eslint diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 6e899e2..8475445 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -29,4 +29,4 @@ jobs: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true - name: Ruby linter - run: bundle exec rubocop + run: bundle exec rubocop -f github diff --git a/Rakefile b/Rakefile index 54c6d50..ffa0877 100644 --- a/Rakefile +++ b/Rakefile @@ -11,7 +11,7 @@ task default: [:rubocop, 'test:ruby'] require 'rake/testtask' namespace :test do desc %(Run all tests) - task all: [:rubocop, 'test:ruby', 'test:js'] + task all: [:rubocop, :lint_javascript, 'test:ruby', 'test:js'] desc %(Test Ruby code) Rake::TestTask.new(:ruby) do |test| @@ -53,6 +53,11 @@ namespace :test do end end +desc %(Lint JavaScript files) +task :lint_javascript do + run_pnpm_script 'eslint' +end + desc %(Regenerate JavaScript files) task :regenerate_javascript do run_pnpm_script 'build' diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..2bd9b28 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,13 @@ +import neostandard from 'neostandard' + +export default [ + { + ignores: [ + 'coverage/**/*.js', + 'dist/**/*.js', + 'test/**/*.js', + 'vendor/**/*.js', + ] + }, + ...neostandard() +] diff --git a/package.json b/package.json index 8919035..e60a0b3 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "homepage": "https://github.com/DavyJonesLocker/client_side_validations-simple_form", "scripts": { - "build": "standard --verbose && rollup -c", + "build": "rollup -c", "test": "test/javascript/run-qunit.mjs" }, "devDependencies": { @@ -28,10 +28,11 @@ "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-node-resolve": "^15.2.1", "chrome-launcher": "^1.1.2", + "eslint": "^9.12.0", + "neostandard": "^0.11.6", "puppeteer-core": "^23.3.0", "rollup": "^4.21.3", - "rollup-plugin-copy": "^3.5.0", - "standard": "^17.1.2" + "rollup-plugin-copy": "^3.5.0" }, "peerDependencies": { "@client-side-validations/client-side-validations": "^0.4.0" diff --git a/test/javascript/run-qunit.mjs b/test/javascript/run-qunit.mjs index 7958366..075c460 100755 --- a/test/javascript/run-qunit.mjs +++ b/test/javascript/run-qunit.mjs @@ -25,9 +25,11 @@ export default (async () => { return new Promise(resolve => setTimeout(resolve, ms)) } + let browser + try { const chromeExecutablePath = chromeLauncher.Launcher.getInstallations()[0] - const browser = await puppeteer.launch({ executablePath: chromeExecutablePath, headless: 'new' }) + browser = await puppeteer.launch({ executablePath: chromeExecutablePath, headless: 'new' }) const page = await browser.newPage() // Attach to browser console log events, and log to node console