Topics

On this page

Last updated on Nov 6, 2024

Configuring IDEs for WordPress Block Development

Optimizing your development environment can have a huge impact on productivity. Below are configurations and plugins you should consider for VSCode and PHPStorm:

ESLint and Stylelint Setup

Ensuring consistent coding standards is crucial when working on team-based projects. ESLint and Stylelint can automate this process.

ESLint: Use .eslintrc to define rules for your JavaScript. WordPress has a recommended set of rules that you can extend.

{
	"root": true,
	"extends": [
		"plugin:@wordpress/eslint-plugin/recommended-with-formatting",
		"plugin:import/recommended",
		"plugin:eslint-comments/recommended"
	],
	"env": { "browser": true },
	"globals": { "wp": true },
	"rules": {
		"jsdoc/check-indentation": "error",
		"@wordpress/dependency-group": "error"
	},
	"overrides": [
		{
			"files": [
				"**/__tests__/**/*.js",
				"**/test/*.js",
				"**/?(*.)test.js",
				"tests/js/**/*.js"
			],
			"extends": ["plugin:jest/all"],
			"rules": {}
		}
	]
}

Stylelint: Manage SCSS code quality using stylelint. This ensures that CSS follows a consistent structure, with rules set in your .stylelintrc.json file.

{
    "extends": "@wordpress/stylelint-config/scss",
    "ignoreFiles": ["**/*.js"],
    "rules": {}
}

Use .stylelintignore to exclude files from linting.

/assets/build/*.css
/tests
/vendor
*.*
!*.css
!*.scss

Explaining .stylelintignore file:

PHPCS configurations

PHPCS ensures that code is clean, consistent, and maintains coding standards across a team while also allowing for the design of custom coding standards.

PHPCS uses phpcs.xml or phpcs.xml.dist file to define rules for your PHP.

phpcs.xml


<ruleset name="VIP-Go-Skeleton">
	<description>WordPress VIP Go Coding Standards</description>

	<rule ref="WordPress-Core">
		<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
		<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
		<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
	</rule>

	<rule ref="WordPress-VIP-Go" />

	<rule ref="WordPressVIPMinimum" />

	<rule ref="WordPress-Docs" />

	<rule ref="PHPCompatibility"/>

	<config name="testVersion" value="7.4-"/>

	<arg name="extensions" value="php"/>
	<arg value="s"/>

	<exclude-pattern>*/node_modules/*</exclude-pattern>
	<exclude-pattern>*/vendor/*</exclude-pattern>
	<exclude-pattern>.github/</exclude-pattern>

	<exclude-pattern>plugins/index.php</exclude-pattern>
	<exclude-pattern>plugins/akismet/</exclude-pattern>
	
	<exclude-pattern>themes/twentynineteen</exclude-pattern>

</ruleset>

Useful IDE Extensions

Here’s a list of recommended extensions to install in VSCode or PHPStorm:


Contributor

Parth Vaswani

Parth

Parth Vaswani

Software Engineer