Skip to content

Commit

Permalink
chore: use wordpress eslint plugin
Browse files Browse the repository at this point in the history
- install wordpress eslint plugin
- use recommended WP rules (minus formatting)
- include type definitions in generator
  • Loading branch information
dustin-jw committed Oct 31, 2023
1 parent 94af045 commit 9407056
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
"sourceType": "module",
"ecmaVersion": "latest"
},
"extends": ["eslint:recommended", "plugin:react/recommended", "plugin:react-hooks/recommended", "prettier"],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:@wordpress/eslint-plugin/recommended-with-formatting",
"prettier"
],
"settings": {
"react": {
"version": "^18.2.0"
Expand Down
8 changes: 6 additions & 2 deletions generators/custom-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const getBlockJsonTemplate = ({ pluginSlug, slugName, name, description, hasView
}
`;

const getEditJSTemplate = ({ name }) => `/**
const getEditJSTemplate = ({ name }) => `/** @typedef {import('@wordpress/element').WPElement} WPElement */
/**
* React hook that is used to mark the block wrapper element.
* It provides all the necessary props like the class name.
*
Expand Down Expand Up @@ -107,7 +109,9 @@ registerBlockType(metadata.name, {
});
`;

const getSaveJSTemplate = ({ name }) => `/**
const getSaveJSTemplate = ({ name }) => `/** @typedef {import('@wordpress/element').WPElement} WPElement */
/**
* React hook that is used to mark the block wrapper element.
* It provides all the necessary props like the class name.
*
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@testing-library/dom": "^9.3.3",
"@testing-library/jest-dom": "^6.1.4",
"@vitest/coverage-istanbul": "^0.34.6",
"@wordpress/eslint-plugin": "^17.1.0",
"@wordpress/scripts": "^26.15.0",
"autoprefixer": "^10.4.16",
"check-node-version": "^4.2.1",
Expand Down

0 comments on commit 9407056

Please sign in to comment.