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 1a28b31828 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
This commit is contained in:
parent
8256d6f18f
commit
15be883595
3 changed files with 3 additions and 18 deletions
2
Makefile
2
Makefile
|
|
@ -33,7 +33,7 @@ COCKPIT_REPO_FILES = \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
COCKPIT_REPO_URL = https://github.com/cockpit-project/cockpit.git
|
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_FILES): $(COCKPIT_REPO_STAMP)
|
||||||
COCKPIT_REPO_TREE = '$(strip $(COCKPIT_REPO_COMMIT))^{tree}'
|
COCKPIT_REPO_TREE = '$(strip $(COCKPIT_REPO_COMMIT))^{tree}'
|
||||||
|
|
|
||||||
10
README.md
10
README.md
|
|
@ -77,7 +77,7 @@ remove manually the symlink:
|
||||||
Cockpit Starter Kit uses [ESLint](https://eslint.org/) to automatically check
|
Cockpit Starter Kit uses [ESLint](https://eslint.org/) to automatically check
|
||||||
JavaScript code style in `.js` and `.jsx` files.
|
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:
|
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
|
Cockpit uses [Stylelint](https://stylelint.io/) to automatically check CSS code
|
||||||
style in `.css` and `scss` files.
|
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:
|
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.
|
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
|
# Running tests locally
|
||||||
|
|
||||||
Run `make check` to build an RPM, install it into a standard Cockpit test VM
|
Run `make check` to build an RPM, install it into a standard Cockpit test VM
|
||||||
|
|
|
||||||
9
build.js
9
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 { cockpitPoEsbuildPlugin } from './pkg/lib/cockpit-po-plugin.js';
|
||||||
import { cockpitRsyncEsbuildPlugin } from './pkg/lib/cockpit-rsync-plugin.js';
|
import { cockpitRsyncEsbuildPlugin } from './pkg/lib/cockpit-rsync-plugin.js';
|
||||||
import { esbuildStylesPlugins } from './pkg/lib/esbuild-common.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 production = process.env.NODE_ENV === 'production';
|
||||||
const useWasm = os.arch() !== 'x64';
|
const useWasm = os.arch() !== 'x64';
|
||||||
const esbuild = (await import(useWasm ? 'esbuild-wasm' : 'esbuild')).default;
|
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();
|
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('-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('-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();
|
const args = parser.parse_args();
|
||||||
|
|
||||||
if (args.rsync)
|
if (args.rsync)
|
||||||
|
|
@ -55,8 +50,6 @@ function notifyEndPlugin() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const cwd = process.cwd();
|
|
||||||
|
|
||||||
// similar to fs.watch(), but recursively watches all subdirectories
|
// similar to fs.watch(), but recursively watches all subdirectories
|
||||||
function watch_dirs(dir, on_change) {
|
function watch_dirs(dir, on_change) {
|
||||||
const callback = (ev, dir, fname) => {
|
const callback = (ev, dir, fname) => {
|
||||||
|
|
@ -95,8 +88,6 @@ const context = await esbuild.context({
|
||||||
target: ['es2020'],
|
target: ['es2020'],
|
||||||
plugins: [
|
plugins: [
|
||||||
cleanPlugin(),
|
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
|
// 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
|
// in the code. This is a problem for index.html and manifest.json which are not imported
|
||||||
copy({
|
copy({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue