Skip to content

Commit

Permalink
Enable prettier ESLint plugin/rules and formatters and format on save (
Browse files Browse the repository at this point in the history
…#14872)

* Enable prettier ESLint plugin/rules

Fix format and lint scripts for Mac

Make prettier default formatter for more file types in VSCode to match the format script

Enable formatOnSave

Format a bunch of json files

* Revert accidental change to package-lock.json

---------

Co-authored-by: Ryan Tremblay <[email protected]>
  • Loading branch information
ryantrem and Ryan Tremblay authored Mar 15, 2024
1 parent c8c8750 commit 59a75da
Show file tree
Hide file tree
Showing 36 changed files with 479 additions and 515 deletions.
5 changes: 2 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const rules = {
},
plugins: [
// "react"
// "prettier", // add this if we want to use prettier error reporting
"prettier",
"jest",
// "@typescript-eslint"
"babylonjs",
Expand All @@ -190,7 +190,7 @@ const rules = {
"plugin:import/typescript",
"plugin:jest/recommended",
// "plugin:jsdoc/recommended",
"prettier",
"plugin:prettier/recommended",
],
settings: {
react: {
Expand Down Expand Up @@ -263,7 +263,6 @@ const rules = {
"no-fallthrough": "warn",
"no-async-promise-executor": "warn",
"no-throw-literal": "error",
// "prettier/prettier": "error" // add this if we want to use prettier error reporting.
},
};

Expand Down
25 changes: 21 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"cSpell.words": [
"babylonjs"
],
"cSpell.words": ["babylonjs"],
"files.exclude": {
"**/node_modules": true,
"**/dist": false,
Expand All @@ -12,9 +10,28 @@
"**/packages/dev/**/ShadersWGSL/**/*.ts": true,
"**/*.fragment.ts": true,
"**/*.vertex.ts": true,
"**/*.compute.ts": true,
"**/*.compute.ts": true
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnSave": true
}
10 changes: 5 additions & 5 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packages": ["packages/**/*"],
"version": "independent",
"allowBranch": ["master", "preview"]
}
{
"packages": ["packages/**/*"],
"version": "independent",
"allowBranch": ["master", "preview"]
}
76 changes: 35 additions & 41 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
{
"extends": "@nrwl/workspace/presets/npm.json",
"npmScope": "babylonjs",
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": [
"build",
"test",
"lint",
"package",
"prepare"
]
}
}
},
"targetDependencies": {
"build": [
{
"target": "build",
"projects": "dependencies"
}
],
"prepare": [
{
"target": "prepare",
"projects": "dependencies"
}
],
"package": [
{
"target": "package",
"projects": "dependencies"
}
]
},
"affected": {
"defaultBase": "main"
}
}
{
"extends": "@nrwl/workspace/presets/npm.json",
"npmScope": "babylonjs",
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": ["build", "test", "lint", "package", "prepare"]
}
}
},
"targetDependencies": {
"build": [
{
"target": "build",
"projects": "dependencies"
}
],
"prepare": [
{
"target": "prepare",
"projects": "dependencies"
}
],
"package": [
{
"target": "package",
"projects": "dependencies"
}
]
},
"affected": {
"defaultBase": "main"
}
}
228 changes: 114 additions & 114 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,114 +1,114 @@
{
"name": "@babylonjs/root",
"version": "1.0.0",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/BabylonJS/bjs-monorepo"
},
"devDependencies": {
"@alex_neo/jest-expect-message": "~1.0.5",
"@dev/build-tools": "^1.0.0",
"@nrwl/tao": "^18.0.4",
"@nrwl/workspace": "^18.0.4",
"@playwright/test": "^1.37.1",
"@types/expect-puppeteer": "~5.0.3",
"@types/fs-extra": "^9.0.13",
"@types/jest": "~27.4.0",
"@types/jest-environment-puppeteer": "~5.0.0",
"@types/jest-expect-message": "~1.0.3",
"@types/puppeteer": "~5.4.4",
"@types/selenium-webdriver": "^4.1.2",
"@typescript-eslint/eslint-plugin": "~6.9.0",
"@typescript-eslint/parser": "~6.9.0",
"ajv": "~8.12.0",
"chokidar": "~3.5.2",
"concurrently": "~8.0.1",
"dotenv": "~16.0.0",
"es-check": "^7.1.1",
"eslint": "^8.11.0",
"eslint-config-prettier": "~9.0.0",
"eslint-formatter-azure-devops": "^1.2.0",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-jest": "~27.4.3",
"eslint-plugin-jsdoc": "~46.2.6",
"eslint-plugin-prettier": "~5.0.0",
"eslint-plugin-tsdoc": "~0.2.14",
"fs-extra": "^10.0.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.5.0",
"jest-junit": "~13.2.0",
"mini-css-extract-plugin": "~2.6.0",
"nx": "^18.0.4",
"prettier": "^3.0.3",
"rimraf": "~3.0.2",
"selenium-webdriver": "^4.3.1",
"ts-jest": "~29.1.0",
"ts-node": "~10.9.0",
"ts-patch": "3.0.2",
"tslib": "^2.4.0",
"typedoc": "^0.25.7",
"typescript": "~5.1.0",
"webpack": "^5.73.0",
"webpack-cli": "^5.1.0"
},
"optionalDependencies": {
"canvas": "~2.11.0"
},
"workspaces": [
"packages/**/*"
],
"scripts": {
"build:dev": "npm run build:assets && npm run build:source && npm run build:declaration -w @tools/babylon-server",
"build:lts": "npm run build:assets && npm run build:source:lts",
"build:source": "tsc -b ./tsconfig.devpackages.json",
"build:source:lts": "npx nx run-many --target=compile --projects=@lts/core,@lts/gui,@lts/loaders,@lts/materials,@lts/post-processes,@lts/procedural-textures,@lts/serializers --parallel=1",
"build:umd": "nx run-many --target=build --parallel --maxParallel=6 --projects=babylonjs,babylonjs-gui,babylonjs-inspector,babylonjs-loaders,babylonjs-materials,babylonjs-serializers,babylonjs-post-process,babylonjs-procedural-textures,babylonjs-node-editor,babylonjs-node-geometry-editor,babylonjs-gui-editor,babylonjs-ktx2decoder,babylonjs-viewer-assets,babylonjs-viewer,babylonjs-accessibility",
"build:es6": "nx run-many --target=build --parallel --maxParallel=6 --projects=@babylonjs/core,@babylonjs/gui,@babylonjs/loaders,@babylonjs/materials,@babylonjs/serializers,@babylonjs/post-processes,@babylonjs/procedural-textures,@babylonjs/node-editor,@babylonjs/node-geometry-editor,@babylonjs/inspector,@babylonjs/gui-editor,@babylonjs/viewer,@babylonjs/shared-ui-components,@babylonjs/accessibility,@babylonjs/ktx2decoder",
"watch:shaders": "build-tools -c build-shaders --global --watch",
"watch:assets": "build-tools -c pa --global --watch",
"watch:source:dev": "tsc -b ./tsconfig.devpackages.json -w",
"watch:source:lts": "npx nx run-many --target=watch:lts --all --parallel --maxParallel=20",
"build:assets": "build-tools -c pa --global",
"build:shaders": "build-tools -c build-shaders --global",
"watch:dev": "npx build-tools -c dw -wa -wd",
"watch:dev:skip-compile": "npx build-tools -c dw -wa -wd -sc",
"watch-dev-test": "concurrently --kill-others -m 2 -n typescript,declarations,server,shaders \"tsc -b ./tsconfig.devpackages.json --watch\" \"npm run watch:declaration -w @tools/babylon-server\" \"npm run watch-shaders\"",
"watch-and-serve:dev": "concurrently \"npm run watch-dev-test\" \"npm run serve -w @tools/babylon-server\"",
"watch-lts": "npx nx run-many --target=watch:lts --all --parallel --maxParallel=20",
"build:babylonjs": "nx build babylonjs",
"build:tools": "npm run build -w @dev/build-tools && npm run build -w eslint-plugin-babylonjs",
"build:test-tools": "npm run build -w @tools/test-tools",
"test": "jest --runInBand",
"test:unit": "jest --selectProjects=unit",
"test:visualization": "jest --selectProjects=visualization --runInBand",
"test:integration": "jest --selectProjects=integration --runInBand && npm run test -w @tools/memory-leak-tests",
"test:performance": "jest --selectProjects=performance --runInBand",
"test:interactions": "jest --selectProjects=interactions --runInBand",
"test:escheck": "nx run-many --target=test:escheck --parallel --maxParallel=6",
"test:docs": "node ./scripts/typedoc-generator.js",
"prepare": "ts-patch install -s && npm run build:tools && npm i @dev/build-tools -D && npm run build:assets && npm run build:test-tools",
"clean": "npx nx run-many --target=clean --all && npm run build:tools",
"format": "npm run format:check && npm run format:fix",
"format:check": "prettier --check ./packages/**/src/**/*.{ts,tsx,js,json,scss,css}",
"format:fix": "prettier --write ./packages/**/src/**/*.{ts,tsx,js,json,scss,css}",
"lint": "npm run lint:check && npm run lint:fix",
"lint:check": "eslint ./packages/**/src/**/*.{ts,tsx,js,json} --quiet",
"lint:check-ci": "eslint -f node_modules/eslint-formatter-azure-devops/index.js ./packages/**/src/**/*.{ts,tsx,js,json} --quiet",
"update-all-dependencies": "npm update -ws",
"prepare-snapshot": "npm run build:snapshot -w @tools/babylon-server && build-tools -c ps",
"start": "concurrently --kill-others -m 2 -n dev-watch,cdn-server \"npm run watch:dev:skip-compile\" \"npm run serve -w @tools/babylon-server\""
},
"engines": {
"node": ">=14.0.0 <21.0.0",
"npm": ">=8.0.0"
},
"changelog": {
"nextVersion": "Unreleased",
"ignoreCommitters": [],
"feature": "New Feature"
},
"dependencies": {
"lerna": "^7.4.2"
}
}
{
"name": "@babylonjs/root",
"version": "1.0.0",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/BabylonJS/bjs-monorepo"
},
"devDependencies": {
"@alex_neo/jest-expect-message": "~1.0.5",
"@dev/build-tools": "^1.0.0",
"@nrwl/tao": "^18.0.4",
"@nrwl/workspace": "^18.0.4",
"@playwright/test": "^1.37.1",
"@types/expect-puppeteer": "~5.0.3",
"@types/fs-extra": "^9.0.13",
"@types/jest": "~27.4.0",
"@types/jest-environment-puppeteer": "~5.0.0",
"@types/jest-expect-message": "~1.0.3",
"@types/puppeteer": "~5.4.4",
"@types/selenium-webdriver": "^4.1.2",
"@typescript-eslint/eslint-plugin": "~6.9.0",
"@typescript-eslint/parser": "~6.9.0",
"ajv": "~8.12.0",
"chokidar": "~3.5.2",
"concurrently": "~8.0.1",
"dotenv": "~16.0.0",
"es-check": "^7.1.1",
"eslint": "^8.11.0",
"eslint-config-prettier": "~9.0.0",
"eslint-formatter-azure-devops": "^1.2.0",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-jest": "~27.4.3",
"eslint-plugin-jsdoc": "~46.2.6",
"eslint-plugin-prettier": "~5.0.0",
"eslint-plugin-tsdoc": "~0.2.14",
"fs-extra": "^10.0.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.5.0",
"jest-junit": "~13.2.0",
"mini-css-extract-plugin": "~2.6.0",
"nx": "^18.0.4",
"prettier": "^3.0.3",
"rimraf": "~3.0.2",
"selenium-webdriver": "^4.3.1",
"ts-jest": "~29.1.0",
"ts-node": "~10.9.0",
"ts-patch": "3.0.2",
"tslib": "^2.4.0",
"typedoc": "^0.25.7",
"typescript": "~5.1.0",
"webpack": "^5.73.0",
"webpack-cli": "^5.1.0"
},
"optionalDependencies": {
"canvas": "~2.11.0"
},
"workspaces": [
"packages/**/*"
],
"scripts": {
"build:dev": "npm run build:assets && npm run build:source && npm run build:declaration -w @tools/babylon-server",
"build:lts": "npm run build:assets && npm run build:source:lts",
"build:source": "tsc -b ./tsconfig.devpackages.json",
"build:source:lts": "npx nx run-many --target=compile --projects=@lts/core,@lts/gui,@lts/loaders,@lts/materials,@lts/post-processes,@lts/procedural-textures,@lts/serializers --parallel=1",
"build:umd": "nx run-many --target=build --parallel --maxParallel=6 --projects=babylonjs,babylonjs-gui,babylonjs-inspector,babylonjs-loaders,babylonjs-materials,babylonjs-serializers,babylonjs-post-process,babylonjs-procedural-textures,babylonjs-node-editor,babylonjs-node-geometry-editor,babylonjs-gui-editor,babylonjs-ktx2decoder,babylonjs-viewer-assets,babylonjs-viewer,babylonjs-accessibility",
"build:es6": "nx run-many --target=build --parallel --maxParallel=6 --projects=@babylonjs/core,@babylonjs/gui,@babylonjs/loaders,@babylonjs/materials,@babylonjs/serializers,@babylonjs/post-processes,@babylonjs/procedural-textures,@babylonjs/node-editor,@babylonjs/node-geometry-editor,@babylonjs/inspector,@babylonjs/gui-editor,@babylonjs/viewer,@babylonjs/shared-ui-components,@babylonjs/accessibility,@babylonjs/ktx2decoder",
"watch:shaders": "build-tools -c build-shaders --global --watch",
"watch:assets": "build-tools -c pa --global --watch",
"watch:source:dev": "tsc -b ./tsconfig.devpackages.json -w",
"watch:source:lts": "npx nx run-many --target=watch:lts --all --parallel --maxParallel=20",
"build:assets": "build-tools -c pa --global",
"build:shaders": "build-tools -c build-shaders --global",
"watch:dev": "npx build-tools -c dw -wa -wd",
"watch:dev:skip-compile": "npx build-tools -c dw -wa -wd -sc",
"watch-dev-test": "concurrently --kill-others -m 2 -n typescript,declarations,server,shaders \"tsc -b ./tsconfig.devpackages.json --watch\" \"npm run watch:declaration -w @tools/babylon-server\" \"npm run watch-shaders\"",
"watch-and-serve:dev": "concurrently \"npm run watch-dev-test\" \"npm run serve -w @tools/babylon-server\"",
"watch-lts": "npx nx run-many --target=watch:lts --all --parallel --maxParallel=20",
"build:babylonjs": "nx build babylonjs",
"build:tools": "npm run build -w @dev/build-tools && npm run build -w eslint-plugin-babylonjs",
"build:test-tools": "npm run build -w @tools/test-tools",
"test": "jest --runInBand",
"test:unit": "jest --selectProjects=unit",
"test:visualization": "jest --selectProjects=visualization --runInBand",
"test:integration": "jest --selectProjects=integration --runInBand && npm run test -w @tools/memory-leak-tests",
"test:performance": "jest --selectProjects=performance --runInBand",
"test:interactions": "jest --selectProjects=interactions --runInBand",
"test:escheck": "nx run-many --target=test:escheck --parallel --maxParallel=6",
"test:docs": "node ./scripts/typedoc-generator.js",
"prepare": "ts-patch install -s && npm run build:tools && npm i @dev/build-tools -D && npm run build:assets && npm run build:test-tools",
"clean": "npx nx run-many --target=clean --all && npm run build:tools",
"format": "npm run format:check && npm run format:fix",
"format:check": "prettier --check \"packages/**/src/**/*.{ts,tsx,js,json,scss,css}\"",
"format:fix": "prettier --write \"packages/**/src/**/*.{ts,tsx,js,json,scss,css}\"",
"lint": "npm run lint:check && npm run lint:fix",
"lint:check": "eslint \"packages/**/src/**/*.{ts,tsx,js,json}\" --quiet",
"lint:check-ci": "eslint -f node_modules/eslint-formatter-azure-devops/index.js \"packages/**/src/**/*.{ts,tsx,js,json}\" --quiet",
"update-all-dependencies": "npm update -ws",
"prepare-snapshot": "npm run build:snapshot -w @tools/babylon-server && build-tools -c ps",
"start": "concurrently --kill-others -m 2 -n dev-watch,cdn-server \"npm run watch:dev:skip-compile\" \"npm run serve -w @tools/babylon-server\""
},
"engines": {
"node": ">=14.0.0 <21.0.0",
"npm": ">=8.0.0"
},
"changelog": {
"nextVersion": "Unreleased",
"ignoreCommitters": [],
"feature": "New Feature"
},
"dependencies": {
"lerna": "^7.4.2"
}
}
Loading

0 comments on commit 59a75da

Please sign in to comment.