~reykjalin/public-inbox

Allow custom coding standards to be used. v1 REJECTED

Garrett Albright: 1
 Allow custom coding standards to be used.

 2 files changed, 32 insertions(+), 3 deletions(-)
Kristófer;

Hi. I think this patch was from some months ago and we had a conversation some other way (IRC? Fediverse?) where you explained that the functionality was already there.
I recall at the time being very confused by this email-based patch submission process, so I’m glad to hear it worked after all, if possibly a bit delayed.

Incidentally I haven’t been able to use your extension much since I’ve been working on projects which don’t particularly bother themselves with such things as “coding standards” but I’ve been starting a new from-scratch PHP 8 project recently so I’ll probably get your extension set up again to work with that project.

Regards;

- Garrett Albright
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~reykjalin/public-inbox/patches/37257/mbox | git am -3
Learn more about email & git

[PATCH] Allow custom coding standards to be used. Export this patch

---
 phpcs.novaextension/Scripts/config.js | 25 +++++++++++++++++++++++--
 phpcs.novaextension/extension.json    | 10 +++++++++-
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/phpcs.novaextension/Scripts/config.js b/phpcs.novaextension/Scripts/config.js
index e2ed53c..2aedebb 100644
--- a/phpcs.novaextension/Scripts/config.js
+++ b/phpcs.novaextension/Scripts/config.js
@@ -33,14 +33,35 @@ const phpcbfExecutablePath = () => {
};

const selectedStandard = () => {
	return nova.workspace.config.get(
	const std = nova.workspace.config.get(
		'com.thorlaksson.phpcs.standard',
		'string'
	);
	if (std === 'Other') {
		return nova.workspace.config.get(
			'com.thorlaksson.phpcs.otherStandard',
			'string'
		);
	}
	else {
		return std;
	}
};

const globalStandard = () => {
	return nova.config.get( 'com.thorlaksson.phpcs.standard', 'string' );
	const std = nova.config.get(
		'com.thorlaksson.phpcs.standard',
		'string'
	);
	if (std === 'Other') {
		return nova.config.get(
			'com.thorlaksson.phpcs.otherStandard',
			'string'
		);
	}
	else {
		return std;
	}
};

const isInDebugMode = () => {
diff --git a/phpcs.novaextension/extension.json b/phpcs.novaextension/extension.json
index ad31f90..20027db 100644
--- a/phpcs.novaextension/extension.json
+++ b/phpcs.novaextension/extension.json
@@ -75,9 +75,17 @@
				"WordPress-Extra",
				"WordPress-Docs",
				"WordPress-Core",
				"SlevomatCodingStandard"
				"SlevomatCodingStandard",
				[ "Other", "Other (specify below)" ]
			]
		},
		{
			"key": "com.thorlaksson.phpcs.otherStandard",
			"title": "Other Standard",
			"description": "To use a standard not specified above, such as one installed separately from PHPCS, enter its name below.",
			"type": "string",
			"default": "",
		},
		{
			"key": "com.thorlaksson.phpcs.runOnChange",
			"title": "Run phpcs",
-- 
2.35.1
Hi Garret, thank you for the patch!

This functionality should already be available by typing in either a
path to a phpcs rule file (such as `phpcs.xml` or
`../other-project/phpcs.xml`) or by typing in the name of the standard
installed alongside phpcs, e.g. via composer (such as `WordPress-Core`).
You type this into the same box that provides the pre-filled standards.

As an example, the projects I work on have a `phpcs.xml.dist` file in
the root of the repositories and I can just manually type in
`phpcs.xml.dist` in the UI to have phpcs use those rules.

Maybe this isn't clear from the UI? I thought I put in a better
description for the option, but that clearly isn't the case.

If that doesn't work, can you try just typing in the name of the
standard you installed? If that doesn't work there's clearly something I
need to update in the plugin code to make that work.


As a side note, if phpcs can detect the standard you installed via
`phpcs -i` that standard should be available in the drop down, maybe
that works for you?


Let me know how that goes! If that doesn't work I'll do some testing
locally to figure out what the problem is.


-Kristófer R.