Skip to content

Commit f0f92b8

Browse files
authored
Release 15.1.3 (#174)
* chore: prepare next dev release * feat: use prettier/plugin-oxc (not for prettier-plugin-eslint though) (#173) * feat: use prettier/plugin-oxc * More updates * Lint all fiels * Add format to lint * Prepare release version 15.1.3 --------- Co-authored-by: datavisyn-bot <> Co-authored-by: Michael Pühringer <[email protected]>
2 parents a1aa6bc + 9da8ee2 commit f0f92b8

17 files changed

+419
-278
lines changed

.prettierrc.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
module.exports = {
2-
endOfLine: 'auto',
3-
singleQuote: true,
4-
trailingComma: 'all',
5-
printWidth: 160,
6-
};
1+
module.exports = require('./config/prettierrc.template');

bin/commands/bundle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { resolve } = require('path');
2+
23
const { call } = require('./utils');
34

45
module.exports = {

bin/commands/copy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const glob = require('glob');
21
const fs = require('fs-extra');
2+
const glob = require('glob');
33
const path = require('path');
44

55
module.exports = {

bin/commands/lint.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,39 @@
1-
const { call } = require('./utils');
1+
const { call, isFormatSeparate } = require('./utils');
22

33
module.exports = {
44
command: 'lint [strings...]',
55
describe: 'Lint a repository using ESLint',
66
builder: (yargs) =>
7-
yargs.option('cache', {
8-
default: true,
9-
type: 'boolean',
10-
}),
7+
yargs
8+
.option('cache', {
9+
default: true,
10+
type: 'boolean',
11+
})
12+
.option('fix', {
13+
default: false,
14+
type: 'boolean',
15+
})
16+
.option('quiet', {
17+
default: false,
18+
type: 'boolean',
19+
})
20+
.option('format', {
21+
// For now, enable format in the CI only. Otherwise, we would have to add the prettier VSCode plugin and adapt workflows for everyone.
22+
default: isFormatSeparate(),
23+
type: 'boolean',
24+
}),
1125
handler: (args) => {
26+
if (args.format) {
27+
// Run prettier separately as it's much faster with the oxc plugin, and the eslint-plugin-prettier doesn't use that apparently.
28+
call(
29+
'prettier',
30+
`prettier ${args.fix ? '--write' : '--check'} --experimental-cli ${(args.strings || []).join(' ')} "src/**/*.ts{,x}" "tests/**/*.ts{,x}" "playwright/**/*.ts{,x}"`,
31+
);
32+
}
33+
1234
call(
1335
'eslint',
14-
`${args.cache ? '--cache' : ''} --no-error-on-unmatched-pattern ${(args.strings || []).join(' ')} "src/**/*.ts{,x}" "tests/**/*.ts{,x}" "playwright/**/*.ts{,x}"`,
36+
`${args.cache ? '--cache' : ''} ${args.fix ? '--fix' : ''} ${args.quiet ? '--quiet' : ''} --cache-location node_modules/.cache/eslint --no-error-on-unmatched-pattern ${(args.strings || []).join(' ')} "src/**/*.ts{,x}" "tests/**/*.ts{,x}" "playwright/**/*.ts{,x}"`,
1537
);
1638
},
1739
};

bin/commands/start.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { resolve } = require('path');
2+
23
const { call } = require('./utils');
34

45
module.exports = {

bin/commands/utils.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { execSync } = require('child_process');
2-
const { resolve, join } = require('path');
32
const fs = require('fs');
3+
const { resolve, join } = require('path');
44

55
/**
66
* Wraps `execSync` with options and error handling.
@@ -33,6 +33,8 @@ const call = (command, args, options = {}) => {
3333
NODE_PATH: nodePath,
3434
// Increase memory limits for node all processes
3535
NODE_OPTIONS: '--max-old-space-size=8192 --max-semi-space-size=512',
36+
// Enable the faster prettier CLI: https://www.solberg.is/prettier-is-fast
37+
PRETTIER_EXPERIMENTAL_CLI: 1,
3638
...(options.env || {}),
3739
...process.env,
3840
},
@@ -43,6 +45,11 @@ const call = (command, args, options = {}) => {
4345
}
4446
};
4547

48+
const isFormatSeparate = () => {
49+
return ['true', '1'].includes(process.env.VISYN_SCRIPTS_FORMAT_SEPARATE?.toLocaleLowerCase());
50+
};
51+
4652
module.exports = {
4753
call,
54+
isFormatSeparate,
4855
};

config/eslint.config.template.js

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
const { defineConfig } = require('eslint/config');
21
const { includeIgnoreFile } = require('@eslint/compat');
3-
const { rules: prettierConfigRules } = require('eslint-config-prettier');
2+
const js = require('@eslint/js');
3+
const { defineConfig } = require('eslint/config');
44
const airbnb = require('eslint-config-airbnb-extended');
5-
const globals = require('globals');
5+
const eslintConfigPrettier = require('eslint-config-prettier/flat');
66
const jest = require('eslint-plugin-jest');
7-
const js = require('@eslint/js');
87
const jsxA11y = require('eslint-plugin-jsx-a11y');
9-
const path = require('node:path');
108
const playwright = require('eslint-plugin-playwright');
11-
const prettierPlugin = require('eslint-plugin-prettier');
9+
const eslintPluginPrettier = require('eslint-plugin-prettier/recommended');
1210
const reactCompiler = require('eslint-plugin-react-compiler');
1311
const unusedImports = require('eslint-plugin-unused-imports');
12+
const globals = require('globals');
13+
const path = require('node:path');
14+
15+
const { isFormatSeparate } = require('../bin/commands/utils');
1416

1517
const jsConfig = [
1618
{
@@ -30,34 +32,11 @@ const reactConfig = [
3032
...airbnb.configs.react.recommended,
3133
];
3234

33-
const typescriptConfig = [
34-
// TypeScript ESLint Plugin
35-
airbnb.plugins.typescriptEslint,
36-
// Airbnb Base TypeScript Config
37-
...airbnb.configs.base.typescript,
38-
// Airbnb React TypeScript Config
39-
...airbnb.configs.react.typescript,
40-
];
41-
42-
const prettierConfig = [
43-
{
44-
name: 'prettier/plugin/config',
45-
plugins: {
46-
prettier: prettierPlugin,
47-
},
48-
},
49-
{
50-
name: 'prettier/config',
51-
rules: {
52-
...prettierConfigRules,
53-
'prettier/prettier': 'error',
54-
},
55-
},
56-
];
35+
const typescriptConfig = [airbnb.plugins.typescriptEslint, ...airbnb.configs.base.typescript, ...airbnb.configs.react.typescript];
5736

5837
const jestConfig = [
5938
{
60-
files: ['{src|tests}/**/*.{test|spec}.ts'],
39+
files: ['{src|tests}/**/*.{test|spec}.{js,ts,jsx,tsx}'],
6140
plugins: { jest },
6241
languageOptions: {
6342
globals: jest.environments.globals.globals,
@@ -68,27 +47,31 @@ const jestConfig = [
6847
const playwrightConfig = [
6948
{
7049
...playwright.configs['flat/recommended'],
71-
files: ['playwright/**/*.{test|spec}.ts'],
50+
files: ['playwright/**/*.{test|spec}.{js,ts,jsx,tsx}'],
7251
},
7352
];
7453

7554
// Helper to disable jsx-a11y rules
76-
const jsxA11yOffRules = Object.keys(jsxA11y.rules).reduce((acc, rule) => {
77-
acc[`jsx-a11y/${rule}`] = 'off';
78-
return acc;
79-
}, {});
55+
const jsxA11yOffRules = Object.fromEntries(Object.keys(jsxA11y.rules).map((rule) => [`jsx-a11y/${rule}`, 'off']));
8056

81-
module.exports = ({ tsconfigRootDir }) =>
57+
module.exports = ({
58+
tsconfigRootDir,
59+
includeJS,
60+
// For now, keep the prettier plugin enabled. Otherwise, we would have to add the prettier VSCode plugin and adapt workflows for everyone.
61+
// The visyn_scripts lint will automatically run prettier if this is enabled.
62+
includePrettierPlugin = !isFormatSeparate(),
63+
}) =>
8264
defineConfig(
8365
includeIgnoreFile(path.resolve('.', '.gitignore')),
8466
...jsConfig,
8567
...reactConfig,
8668
...typescriptConfig,
87-
...prettierConfig,
8869
...jestConfig,
8970
...playwrightConfig,
71+
// The prettier plugin contains both the config and the rule to run prettier as an eslint rule, whereas the config just disables conflicting rules (i.e. if you run prettier separately).
72+
...(includePrettierPlugin ? [eslintPluginPrettier] : [eslintConfigPrettier]),
9073
{
91-
files: ['**/*.{ts,tsx,cts,mts}'],
74+
files: ['**/*.{ts,tsx,cts,mts}', ...(includeJS ? ['**/*.{js,jsx,cjs,mjs}'] : [])],
9275
plugins: {
9376
'unused-imports': unusedImports,
9477
},
@@ -105,14 +88,15 @@ module.exports = ({ tsconfigRootDir }) =>
10588
project: `./tsconfig.eslint.json`,
10689
},
10790
globals: {
91+
...globals.commonjs,
92+
...globals.jest,
10893
...globals.node,
10994
...globals.browser,
11095
...globals.es6,
11196
Atomics: 'readonly',
11297
SharedArrayBuffer: 'readonly',
11398
},
11499
},
115-
116100
rules: {
117101
...jsxA11yOffRules,
118102
'arrow-body-style': 'off',
@@ -159,7 +143,7 @@ module.exports = ({ tsconfigRootDir }) =>
159143
},
160144
],
161145
'prefer-arrow-callback': 'warn',
162-
'@typescript-eslint/no-require-imports': 'warn',
146+
'@typescript-eslint/no-require-imports': 'off',
163147
'@typescript-eslint/consistent-indexed-object-style': 'off',
164148
'@typescript-eslint/consistent-type-definitions': 'off',
165149
'@typescript-eslint/ban-ts-comment': 'warn',

config/jest_export_maps_resolver.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// temporary workaround while we wait for https://github.com/facebook/jest/issues/9771
2-
// eslint-disable-next-line import-x/no-extraneous-dependencies
32
const resolver = require('enhanced-resolve').create.sync({
43
conditionNames: ['require', 'node', 'default', 'import'],
54
extensions: ['.js', '.json', '.node', '.ts', '.tsx'],

config/prettierrc.template.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
module.exports = {
2+
// Use the oxc plugin for speed: https://www.solberg.is/prettier-is-fast
3+
plugins: ['@prettier/plugin-oxc'],
24
endOfLine: 'auto',
35
singleQuote: true,
46
trailingComma: 'all',

config/rspack.config.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/* eslint-disable prefer-const */
22
/* eslint-disable import-x/no-dynamic-require */
3-
const path = require('path');
4-
const fs = require('fs');
5-
const { execSync } = require('child_process');
3+
const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');
64
const { defineConfig } = require('@rspack/cli');
7-
const { TsCheckerRspackPlugin } = require('ts-checker-rspack-plugin');
8-
const dotenv = require('dotenv');
9-
const DotenvPlugin = require('dotenv-webpack');
10-
const dotenvExpand = require('dotenv-expand');
115
const { CopyRspackPlugin, DefinePlugin, SwcJsMinimizerRspackPlugin } = require('@rspack/core');
126
const ReactRefreshPlugin = require('@rspack/plugin-react-refresh');
7+
const { execSync } = require('child_process');
8+
const dotenv = require('dotenv');
9+
const dotenvExpand = require('dotenv-expand');
10+
const DotenvPlugin = require('dotenv-webpack');
11+
const fs = require('fs');
1312
const HtmlWebpackPlugin = require('html-webpack-plugin');
14-
const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');
13+
const path = require('path');
14+
const { TsCheckerRspackPlugin } = require('ts-checker-rspack-plugin');
1515

1616
// Load the current .env and expand it
1717
const parsedEnv = dotenvExpand.expand(dotenv.config());
@@ -420,7 +420,7 @@ module.exports = (webpackEnv, argv) => {
420420
fs.existsSync(workspaceMetaDataFile) && {
421421
from: workspaceMetaDataFile,
422422
to: path.join(workspacePath, 'bundles', 'phoveaMetaData.json'),
423-
// @ts-ignore TODO: check why https://webpack.js.org/plugins/copy-webpack-plugin/#transform is not in the typing.
423+
// @ts-expect-error TODO: check why https://webpack.js.org/plugins/copy-webpack-plugin/#transform is not in the typing.
424424
transform: () => {
425425
function resolveScreenshot(appDirectory) {
426426
const f = path.join(appDirectory, './media/screenshot.png');

0 commit comments

Comments
 (0)