Skip to content

Commit

Permalink
Clean up old project-level eslint and prettier scripts (#40434)
Browse files Browse the repository at this point in the history
A few projects were either imported with eslint and prettier
dependencies and scripts in package.json that they had while they were
still standalone repos, or were forked from such repos. In preparation
for the big eslint 9 upgrade, let's clean those up since they're not
used in the monorepo.

Four projects have eslint's `prettier/prettier` rule disabled. Let's
enable those and let prettier do its thing. This also required updating
the root `.prettierrc.js` to actually load `prettier-plugin-svelte`.
  • Loading branch information
anomiex authored Dec 3, 2024
1 parent eafa13a commit 80020f7
Show file tree
Hide file tree
Showing 55 changed files with 396 additions and 417 deletions.
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
// Load plugins from sub-project so we don't have to clutter the monorepo root with them.
plugins: require( './tools/js-tools/prettier-plugins.js' ),

useTabs: true,
tabWidth: 2,
printWidth: 100,
Expand Down
42 changes: 6 additions & 36 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Add `NODE_OPTIONS=--experimental-vm-modules` to test run, apparently the `require()` in `.prettierrc.js` somehow requires that now. 🤷


Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"license": "GPL-2.0-or-later",
"author": "Automattic",
"scripts": {
"test": "jest --config=tests/jest.config.cjs",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --config=tests/jest.config.cjs",
"test-coverage": "pnpm run test --coverage"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove unused eslint deps.


2 changes: 0 additions & 2 deletions projects/js-packages/boost-score-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
},
"devDependencies": {
"@automattic/jetpack-webpack-config": "workspace:*",
"@typescript-eslint/parser": "6.21.0",
"eslint": "8.57.1",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"typescript": "5.0.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: removed

Remove unused prettier dep.
1 change: 0 additions & 1 deletion projects/js-packages/critical-css-gen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"path-browserify": "1.0.1",
"playwright": "1.45.1",
"playwright-core": "^1.45.1",
"prettier": "npm:wp-prettier@3.0.3",
"process": "0.11.10",
"source-map": "0.7.4",
"source-map-js": "1.2.0",
Expand Down
1 change: 0 additions & 1 deletion projects/js-packages/image-guide/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ module.exports = {
'import/no-unresolved': 0,
'import/order': 0,
'no-nested-ternary': 0,
'prettier/prettier': 0,
camelcase: 0,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Enable prettier via eslint, and fix issues. Also remove unused eslint deps and package.json scripts.


4 changes: 0 additions & 4 deletions projects/js-packages/image-guide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
"dev-validate-ts": "tsc --watch --pretty --strict false # Note: Disable Strict mode to avoid noisy development, while keeping strict errors visible in IDEs.",
"dev-compile": "pnpm run clear-dist && rollup -c -w",
"dev": "concurrently 'pnpm:dev-validate-ts' 'pnpm:dev-compile'",
"reformat-files": "../../../tools/js-tools/node_modules/.bin/prettier --ignore-path .eslintignore --write --plugin-search-dir=. ./**/*.{svelte,js,ts,json}",
"lint": "pnpm run reformat-files && echo 'Running eslint...' && pnpm eslint app/assets/src/js tests/e2e --fix && echo '✔ prettier and eslint ran successfully.'",
"clear-dist": "rm -rf app/assets/dist/*",
"test-coverage": "pnpm run test --coverage",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --config=tests/jest.config.cjs"
Expand All @@ -44,8 +42,6 @@
"@rollup/plugin-replace": "5.0.2",
"@rollup/plugin-terser": "0.4.3",
"@rollup/plugin-typescript": "12.1.0",
"@typescript-eslint/parser": "6.21.0",
"eslint": "8.57.1",
"jest": "29.7.0",
"postcss": "8.4.47",
"rollup": "3.29.5",
Expand Down
49 changes: 25 additions & 24 deletions projects/js-packages/image-guide/src/ui/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,51 +14,51 @@
* This onMount is triggered when the window loads
* and the Image Guide UI is first
*/
onMount(() => {
stores.forEach(store => store.updateDimensions());
});
onMount( () => {
stores.forEach( store => store.updateDimensions() );
} );
function closeDetails(e) {
function closeDetails( e ) {
// Don't exit when hovering the Portal
if (
e.relatedTarget &&
// Don't exit when hovering the Popup
e.relatedTarget.classList.contains('keep-guide-open')
e.relatedTarget.classList.contains( 'keep-guide-open' )
) {
return;
}
show = false;
}
function getGuideSize(width = -1, height = -1): GuideSize {
if (width < 200 || height < 200) {
function getGuideSize( width = -1, height = -1 ): GuideSize {
if ( width < 200 || height < 200 ) {
return 'micro';
} else if (width < 400 || height < 400) {
} else if ( width < 400 || height < 400 ) {
return 'small';
}
return 'normal';
}
function toggleBackdrop(on = false) {
if (on) {
stores.forEach(store => store.node.classList.add('jetpack-boost-guide__backdrop'));
function toggleBackdrop( on = false ) {
if ( on ) {
stores.forEach( store => store.node.classList.add( 'jetpack-boost-guide__backdrop' ) );
} else {
stores.forEach(store => store.node.classList.remove('jetpack-boost-guide__backdrop'));
stores.forEach( store => store.node.classList.remove( 'jetpack-boost-guide__backdrop' ) );
}
}
// Use the first image available in the stores to determine the guide size
const sizeOnPage = stores[0].sizeOnPage;
$: size = getGuideSize($sizeOnPage.width, $sizeOnPage.height);
const sizeOnPage = stores[ 0 ].sizeOnPage;
$: size = getGuideSize( $sizeOnPage.width, $sizeOnPage.height );
$: toggleBackdrop(show !== false);
$: toggleBackdrop( show !== false );
let position = {
top: 0,
left: 0,
};
function hover(e: CustomEvent) {
function hover( e: CustomEvent ) {
const detail = e.detail;
const index = detail.index;
position = detail.position;
Expand All @@ -69,8 +69,9 @@
* Only show image guide if at least one of the images
* has a file size available.
*/
const hasItemsWithFileSize = derived(stores.map(s => s.fileSize), $fileSizes =>
$fileSizes.some(fileSize => fileSize.width !== -1 && fileSize.height !== -1)
const hasItemsWithFileSize = derived(
stores.map( s => s.fileSize ),
$fileSizes => $fileSizes.some( fileSize => fileSize.width !== -1 && fileSize.height !== -1 )
);
</script>

Expand All @@ -94,20 +95,20 @@
Intentionally using only a single component here.
See <Popup> component source for details.
-->
<Popup store={stores[show]} {size} {position} on:mouseleave={closeDetails} />
<Popup store={stores[ show ]} {size} {position} on:mouseleave={closeDetails} />
{/if}
</div>
{/if}

<style lang="scss">
:global(.jetpack-boost-guide) {
&:not(.relative) {
:global( .jetpack-boost-guide ) {
&:not( .relative ) {
position: absolute;
top: 0;
left: 0;
}
}
:global(.jetpack-boost-guide.relative) {
:global( .jetpack-boost-guide.relative ) {
position: relative;
}
.guide {
Expand Down Expand Up @@ -153,10 +154,10 @@
margin-bottom: 15px;
}
:global(.jetpack-boost-guide__backdrop) {
:global( .jetpack-boost-guide__backdrop ) {
transition:
opacity 0.2s ease-in-out,
filter 0.2s ease-in-out;
filter: brightness(0.3);
filter: brightness( 0.3 );
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove unused eslint and prettier scripts from package.json.


2 changes: 0 additions & 2 deletions projects/js-packages/react-data-sync-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"build": "pnpm run clean && webpack",
"clean": "rm -rf build/",
"watch": "pnpm run build && pnpm webpack watch",
"reformat-files": "../../../tools/js-tools/node_modules/.bin/prettier --ignore-path .eslintignore --write --plugin-search-dir=. ./src/**/*.ts",
"lint": "pnpm run reformat-files && echo 'Running eslint...' && pnpm eslint src --fix && echo '✔ prettier and eslint ran successfully.'",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --config=tests/jest.config.cjs",
"test-coverage": "pnpm run test --coverage"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove unused eslint and prettier scripts from package.json, and unused eslint deps.


4 changes: 0 additions & 4 deletions projects/js-packages/svelte-data-sync-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@
"build": "pnpm run clean && webpack",
"clean": "rm -rf build/",
"watch": "pnpm run build && pnpm webpack watch",
"reformat-files": "../../../tools/js-tools/node_modules/.bin/prettier --ignore-path .eslintignore --write --plugin-search-dir=. ./src/**/*.ts",
"lint": "pnpm run reformat-files && echo 'Running eslint...' && pnpm eslint src --fix && echo '✔ prettier and eslint ran successfully.'",
"test-coverage": "pnpm run test --coverage",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --config=tests/jest.config.cjs"
},
"devDependencies": {
"@automattic/jetpack-webpack-config": "workspace:*",
"@typescript-eslint/parser": "6.21.0",
"eslint": "8.57.1",
"jest": "29.7.0",
"svelte": "4.2.19",
"tslib": "2.5.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove unused eslint and prettier scripts from package.json


2 changes: 0 additions & 2 deletions projects/js-packages/videopress-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
"build": "pnpm run clean && webpack",
"clean": "rm -rf build/",
"watch": "pnpm run build && pnpm webpack watch",
"reformat-files": "../../../tools/js-tools/node_modules/.bin/prettier --ignore-path .eslintignore --write --plugin-search-dir=. ./src/**/*.ts",
"lint": "pnpm run reformat-files && echo 'Running eslint...' && pnpm eslint src --fix && echo '✔ prettier and eslint ran successfully.'",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --config=tests/jest.config.cjs",
"test-coverage": "pnpm run test --coverage"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove unused eslint script from package.json


1 change: 0 additions & 1 deletion projects/packages/jetpack-mu-wpcom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"build-js": "pnpm clean && webpack",
"build-production": "echo 'Not implemented.'",
"build-production-js": "NODE_ENV=production BABEL_ENV=production pnpm build-js",
"lint": "eslint --ext .js,.jsx,.cjs,.mjs,.ts,.tsx .",
"clean": "rm -rf src/build/",
"watch": "pnpm run build-production-js && pnpm webpack watch",
"e2e-tests": "playwright test --config src/features/verbum-comments/playwright.config.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove unused prettier dep.


1 change: 0 additions & 1 deletion projects/packages/search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"postcss": "8.4.47",
"postcss-custom-properties": "12.1.7",
"postcss-loader": "6.2.0",
"prettier": "npm:wp-prettier@3.0.3",
"sass": "1.64.1",
"sass-loader": "12.4.0",
"size-limit": "11.1.6",
Expand Down
Loading

0 comments on commit 80020f7

Please sign in to comment.