Skip to content

Commit

Permalink
Merge pull request #26 from happyprime/fix/make-js-lighter
Browse files Browse the repository at this point in the history
Replace @wordpress/scripts with cleaner build/linting
  • Loading branch information
jeremyfelt authored Mar 1, 2024
2 parents befea03 + 59905d9 commit bf61003
Show file tree
Hide file tree
Showing 8 changed files with 8,047 additions and 26,840 deletions.
23 changes: 23 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
extends: [
'plugin:import/recommended',
'plugin:jsdoc/recommended',
'plugin:jsx-a11y/recommended',
'plugin:prettier/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
],
env: {
browser: true,
},
ignorePatterns: ['build/**/*.js', 'vendor/**/*.js'],
rules: {
'no-console': ['warn', { allow: ['error'] }],
'import/no-unresolved': [2, { ignore: ['^@wordpress/'] }],
},
settings: {
react: {
version: '18',
},
},
};
22 changes: 22 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const config = {
useTabs: true,
tabWidth: 4,
printWidth: 80,
singleQuote: true,
trailingComma: 'es5',
bracketSameLine: false,
bracketSpacing: true,
semi: true,
arrowParens: 'always',
parenSpacing: true,
overrides: [
{
files: '*.{css,sass,scss}',
options: {
singleQuote: false,
},
},
],
};

module.exports = config;
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-blocks', 'wp-dom-ready'), 'version' => '13623f35a22fbab135b9');
<?php return array('dependencies' => array('wp-blocks', 'wp-dom-ready'), 'version' => '105d3c0577a1f1b9d0cf');
2 changes: 1 addition & 1 deletion build/index.js

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

34,735 changes: 7,913 additions & 26,822 deletions package-lock.json

Large diffs are not rendered by default.

53 changes: 44 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,57 @@
"name": "turn-comments-off",
"version": "1.3.0",
"description": "Turn comments off everywhere in WordPress",
"scripts": {
"build": "wp-scripts build",
"lint": "wp-scripts lint-js",
"fix": "wp-scripts lint-js --fix"
},
"author": "Happy Prime",
"license": "GPL-2.0-or-later",
"keywords": [
"comments",
"wordpress"
],
"homepage": "https://github.com/happyprime/turn-comments-off#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/happyprime/turn-comments-off.git"
},
"author": "Happy Prime",
"license": "GPL-2.0-or-later",
"bugs": {
"url": "https://github.com/happyprime/turn-comments-off/issues"
},
"homepage": "https://github.com/happyprime/turn-comments-off#readme",
"engines": {
"node": ">=20",
"npm": ">=10"
},
"devDependencies": {
"@wordpress/scripts": "^26.15.0"
"@babel/core": "^7.24.0",
"@babel/eslint-parser": "^7.23.10",
"@babel/plugin-transform-runtime": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"@babel/preset-react": "^7.23.3",
"@wordpress/browserslist-config": "^5.35.0",
"@wordpress/dependency-extraction-webpack-plugin": "^5.3.0",
"@wordpress/npm-package-json-lint-config": "^4.37.0",
"babel-loader": "^9.1.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.2.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"npm-package-json-lint": "^7.1.0",
"webpack": "^5.90.3",
"webpack-cli": "^5.1.4"
},
"scripts": {
"build": "webpack --mode production",
"start": "webpack --mode development --watch",
"lint": "eslint .",
"fix": "eslint . --fix",
"lint:package": "node ./node_modules/npm-package-json-lint/dist/cli.js ./"
},
"browserslist": [
"extends @wordpress/browserslist-config"
],
"npmpackagejsonlint": {
"extends": "@wordpress/npm-package-json-lint-config"
}
}
13 changes: 6 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { getBlockType, unregisterBlockType } from '@wordpress/blocks';
import domReady from '@wordpress/dom-ready';

// Unregister comment-related blocks provided by WordPress core.
domReady( () => {
domReady(() => {
const blocks = [
'core/comments',
'core/comments-query-loop', // Replaced by core/comments in Gutenberg 13.7.

'core/comment-author-avatar',
'core/comment-author-name',
'core/comment-content',
Expand All @@ -29,9 +28,9 @@ domReady( () => {
'core/post-comments-link',
];

blocks.forEach( ( block ) => {
if ( undefined !== getBlockType( block ) ) {
unregisterBlockType( block );
blocks.forEach((block) => {
if (undefined !== getBlockType(block)) {
unregisterBlockType(block);
}
} );
} );
});
});
37 changes: 37 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const path = require('path');
const DependencyExtractionWebpackPlugin = require('@wordpress/dependency-extraction-webpack-plugin');

module.exports = {
entry: {
index: path.resolve(__dirname, 'src', 'index.js'),
},
output: {
path: path.resolve(__dirname, 'build'),
filename: '[name].js',
},
optimization: {
minimize: true,
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: ['@babel/plugin-transform-runtime'],
},
},
},
],
},
plugins: [new DependencyExtractionWebpackPlugin()],

// External dependencies that should not be bundled.
externals: {
react: 'React',
'react-dom': 'ReactDOM',
},
};

0 comments on commit bf61003

Please sign in to comment.