diff --git a/HACKING.md b/HACKING.md index f4b23491774f..fe1a048c343e 100644 --- a/HACKING.md +++ b/HACKING.md @@ -94,9 +94,6 @@ pkg/lib/), you can also build all pages: ./build.js -w -Note that this enables eslint by default -- if you want to disable it, run it -with `-e`/`--no-eslint`. - Reload cockpit in your browser after page is built. Press `Ctrl`-`C` to stop watch mode once you are done with changing the code. @@ -232,7 +229,7 @@ The tests require at least `pytest` 7.0.0 or higher to run. Cockpit uses [ESLint](https://eslint.org/) to automatically check JavaScript code style in `.js` and `.jsx` files. -The linter is executed on every build. +The linter is executed as part of `test/static-code`. For developer convenience, the ESLint can be started explicitly by: diff --git a/build.js b/build.js index 19110eb42a75..51b95450ec08 100755 --- a/build.js +++ b/build.js @@ -50,7 +50,6 @@ const qunitOptions = { 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" }); -parser.add_argument('-e', '--no-eslint', { action: 'store_true', help: "Disable eslint linting", default: production }); parser.add_argument('onlydir', { nargs: '?', help: "The pkg/ to build (eg. base1, shell, ...)", metavar: "DIRECTORY" }); const args = parser.parse_args(); @@ -111,7 +110,6 @@ async function build() { const cockpitPoEsbuildPlugin = (await import('./pkg/lib/cockpit-po-plugin.js')).cockpitPoEsbuildPlugin; const cockpitRsyncEsbuildPlugin = (await import('./pkg/lib/cockpit-rsync-plugin.js')).cockpitRsyncEsbuildPlugin; const cockpitTestHtmlPlugin = (await import('./pkg/lib/esbuild-test-html-plugin.js')).cockpitTestHtmlPlugin; - const eslintPlugin = (await import('./pkg/lib/esbuild-eslint-plugin.js')).eslintPlugin; const esbuildStylesPlugins = (await import('./pkg/lib/esbuild-common.js')).esbuildStylesPlugins; @@ -124,7 +122,6 @@ async function build() { ]; const pkgPlugins = [ - ...args.no_eslint ? [] : [eslintPlugin({ filter: /pkg\/.*\.(jsx?|js?)$/ })], cockpitJSResolvePlugin, ...esbuildStylesPlugins ]; @@ -181,7 +178,6 @@ async function build() { ...qunitOptions, entryPoints: testEntryPoints, plugins: [ - ...args.no_eslint ? [] : [eslintPlugin({ filter: /pkg\/.*\.(jsx?|js?)$/ })], cockpitTestHtmlPlugin({ testFiles: tests }), ], }); @@ -200,7 +196,6 @@ async function build() { ...qunitOptions, entryPoints: testEntryPoints, plugins: [ - ...args.no_eslint ? [] : [eslintPlugin({ filter: /pkg\/.*\.(jsx?|js?)$/ })], cockpitTestHtmlPlugin({ testFiles: tests }), ], }); diff --git a/pkg/lib/esbuild-eslint-plugin.js b/pkg/lib/esbuild-eslint-plugin.js deleted file mode 100644 index e78657cb19c7..000000000000 --- a/pkg/lib/esbuild-eslint-plugin.js +++ /dev/null @@ -1,32 +0,0 @@ -// Replace with plugin from npmjs once they become good enough -// Candidate 1: requires https://github.com/to-codando/esbuild-plugin-linter/issues/1 and https://github.com/to-codando/esbuild-plugin-linter/issues/3 to get fixed -// Candidate 2: requires https://github.com/robinloeffel/esbuild-plugin-eslint/issues/4 and https://github.com/robinloeffel/esbuild-plugin-eslint/issues/5 to get fixed - -import { ESLint } from 'eslint'; - -const NAME = 'eslintPlugin'; - -export const eslintPlugin = ({ filter = /src\/.*\.(jsx?|js?)$/ } = {}) => ({ - name: NAME, - setup(build) { - const filesToLint = []; - const eslint = new ESLint(); - - build.onLoad({ filter }, ({ path }) => { - filesToLint.push(path); - }); - - build.onEnd(async () => { - const result = await eslint.lintFiles(filesToLint); - const formatter = await eslint.loadFormatter('stylish'); - const output = formatter.format(result); - if (output.length > 0) { - console.log(output); // eslint-disable no-console - return { - errors: [{ pluginName: NAME, text: 'ESLint errors found' }] - }; - } - return null; - }); - }, -});