WordPress / better-code-editing

[✅ Merged into 4.9-alpha] Better Code Editing WordPress plugin
https://wordpress.org/plugins/better-code-editing/
37 stars 16 forks source link

Add a way to customize CSSLint rules #38

Closed obenland closed 7 years ago

obenland commented 7 years ago

Maybe this should be part of a bigger discussion about finding a way to customize certain parts of CodeMirror. I was going back and forth between individual customization files like I'm proposing in this PR, and one combined file, something like wp-codemirror.js or something.

We should also go through the rules CSSLint comes with and see which ones we want to keep or not. /cc @melchoyce

Fixes #26.

melchoyce commented 7 years ago

Thanks @obenland. Do you think I should start a new issue to discuss which rules we want to include?

obenland commented 7 years ago

I think we can do that here and then add those in

melchoyce commented 7 years ago

Cool. Thinking we should actually be pretty conservative about which rules we're including. I'm thinking...

obenland commented 7 years ago

@westonruter Given how many rules we remove here, I wonder if it would be better to create a custom build of csslint than to have the default script add all the rules and us the overwriting them later on? I'd have one ready to go.

westonruter commented 7 years ago

@obenland My only concern there would be if someone would like to enable those rules via filtering, but if they aren't part of the build then they wouldn't be able to do it. How is a custom build made?

obenland commented 7 years ago

How is a custom build made?

I followed the instructions here, removed the unwanted rule files from src/rules, and ran grunt concat. The resulting file can then be found in dist.

westonruter commented 7 years ago

I'm trying an alternate approach to defining the rules in af724cc. This could allow us to use PHP to filter the rules that the user wants. It's a bit hacky in how it CSSLint doesn't have a removeRule method, so it has to clear all of them and then re-add the ones that we want.

Thoughts?

There are still a few warnings shown in the style.css for Twenty Seventeen, but there are far fewer than before.

westonruter commented 7 years ago

I'm working on the refactor to add the wp.codeEditor abstraction.