From 15be8835955f81c212a56cc262cb51a8b2914e0e Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 7 Feb 2024 18:51:46 +0100 Subject: [PATCH] Move eslint/stylelint to static-code tests stylelint 16 causes a deadlock/crash in esbuild [1]. There's no movement on that issue, and we want stylelint 16 to be able to support the Browser Baseline 2023. Follow https://github.com/cockpit-project/cockpit/commit/1a28b31828e and move the linters into test/static-code. This also starts to lint files which are outside of esbuild's realm, such as documentation and examples. [1] https://github.com/evanw/esbuild/issues/3542 --- Makefile | 2 +- README.md | 10 ++-------- build.js | 9 --------- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index cc3a7ad..10dd33e 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ COCKPIT_REPO_FILES = \ $(NULL) COCKPIT_REPO_URL = https://github.com/cockpit-project/cockpit.git -COCKPIT_REPO_COMMIT = bc12d5e116b56ebc5509fde7191a2ac5c09b1018 # 310.1 + 17 commits +COCKPIT_REPO_COMMIT = 1a28b31828e309aa2aba6076b1bcc5ee841ac8ea # 310.1 + 30 commits $(COCKPIT_REPO_FILES): $(COCKPIT_REPO_STAMP) COCKPIT_REPO_TREE = '$(strip $(COCKPIT_REPO_COMMIT))^{tree}' diff --git a/README.md b/README.md index 24730e9..575477d 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ remove manually the symlink: Cockpit Starter Kit uses [ESLint](https://eslint.org/) to automatically check JavaScript code style in `.js` and `.jsx` files. -eslint is executed within every build. +eslint is executed as part of `test/static-code`, aka. `make codecheck`. For developer convenience, the ESLint can be started explicitly by: @@ -94,7 +94,7 @@ Rules configuration can be found in the `.eslintrc.json` file. Cockpit uses [Stylelint](https://stylelint.io/) to automatically check CSS code style in `.css` and `scss` files. -styleint is executed within every build. +styleint is executed as part of `test/static-code`, aka. `make codecheck`. For developer convenience, the Stylelint can be started explicitly by: @@ -106,12 +106,6 @@ Violations of some rules can be fixed automatically by: Rules configuration can be found in the `.stylelintrc.json` file. -During fast iterative development, you can also choose to not run eslint/stylelint. -This speeds up the build and avoids build failures due to e. g. ill-formatted -css or other issues: - - $ ./build.js -es - # Running tests locally Run `make check` to build an RPM, install it into a standard Cockpit test VM diff --git a/build.js b/build.js index 87bdae4..4210743 100755 --- a/build.js +++ b/build.js @@ -11,19 +11,14 @@ import { cockpitCompressPlugin } from './pkg/lib/esbuild-compress-plugin.js'; import { cockpitPoEsbuildPlugin } from './pkg/lib/cockpit-po-plugin.js'; import { cockpitRsyncEsbuildPlugin } from './pkg/lib/cockpit-rsync-plugin.js'; import { esbuildStylesPlugins } from './pkg/lib/esbuild-common.js'; -import { eslintPlugin } from './pkg/lib/esbuild-eslint-plugin.js'; -import { stylelintPlugin } from './pkg/lib/esbuild-stylelint-plugin.js'; const production = process.env.NODE_ENV === 'production'; const useWasm = os.arch() !== 'x64'; const esbuild = (await import(useWasm ? 'esbuild-wasm' : 'esbuild')).default; -const lintDefault = process.env.LINT ? process.env.LINT === '0' : production; const parser = (await import('argparse')).default.ArgumentParser(); parser.add_argument('-r', '--rsync', { help: "rsync bundles to ssh target after build", metavar: "HOST" }); parser.add_argument('-w', '--watch', { action: 'store_true', help: "Enable watch mode", default: process.env.ESBUILD_WATCH === "true" }); -parser.add_argument('-e', '--no-eslint', { action: 'store_true', help: "Disable eslint linting", default: lintDefault }); -parser.add_argument('-s', '--no-stylelint', { action: 'store_true', help: "Disable stylelint linting", default: lintDefault }); const args = parser.parse_args(); if (args.rsync) @@ -55,8 +50,6 @@ function notifyEndPlugin() { }; } -const cwd = process.cwd(); - // similar to fs.watch(), but recursively watches all subdirectories function watch_dirs(dir, on_change) { const callback = (ev, dir, fname) => { @@ -95,8 +88,6 @@ const context = await esbuild.context({ target: ['es2020'], plugins: [ cleanPlugin(), - ...args.no_stylelint ? [] : [stylelintPlugin({ filter: new RegExp(cwd + '/src/.*\\.(css?|scss?)$') })], - ...args.no_eslint ? [] : [eslintPlugin({ filter: new RegExp(cwd + '/src/.*\\.(jsx?|js?)$') })], // Esbuild will only copy assets that are explicitly imported and used // in the code. This is a problem for index.html and manifest.json which are not imported copy({