-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MNT Add linting #387
MNT Add linting #387
Conversation
5682c5c
to
9a9d21a
Compare
package.json
Outdated
"lint": "yarn install && yarn lint-md && yarn lint-js && yarn lint-php && yarn lint-language", | ||
"lint-fix": "yarn install && yarn lint-md --fix; yarn lint-js --fix; yarn lint-php --fix; echo 'Fixed all auto-fixable problems'", | ||
"lint-md": "yarn install && markdownlint-cli2 en/**/*.md", | ||
"lint-js": "yarn install && eslint en", | ||
"lint-php": "composer install --prefer-dist --no-progress --ansi --no-interaction --no-scripts --no-plugins --optimize-autoloader && vendor/bin/mdphpcs en", | ||
"lint-language": "yarn install && vale sync && vale en" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The individual scripts are used by CI so we can clearly see what is failing and where, without having either a massive hard-to-parse output or a failure in one script which results in skipping the rest of the linting.
The main lint
script is useful to run locally to double check all is well before pushing changes.
The lint-fix
script is useful to run locally to fix anything that can be autofixed, without really caring what script is fixing it.
In the files change tab at the bottom there a "Unchanged files with check annotations" - any idea if that's something that can be configured off at the github actions level, or if it's a user preference thing? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we should split off the vale language linting into its own card and tackle separately from the non-language stuff like indentation first.
Once that's sorted then look at doing language second because at that point we'll get a mountain of warnings tell us that we should consider replacing words like "simple" and "could"
Looks like that's just something GitHub is doing, which is a pain. There's (a very small amount of) discussion about it at actions/toolkit#457 I think the only reason we don't see this on any PRs in our other repos is because we don't have any pre-existing linting issues in those other repos. Once we've fixed them all in this PR, we won't see them anymore here either. |
After discussing this offline I agree that it will be easier and faster to review the structural linting first, and deal with the language stuff separately as that could change the meanings of what's written and therefore requires a higher level of scrutiny. |
0776baa
to
8779108
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we exclude old changelogs (but not new ones, maybe do something with git branch -r
)? There are A LOT of linting issues in old changelogs and to me it seems wrong to update old changelogs since they're a snapshot in time, particularly once we add in the language linting.
Discussed offline - the markdown linting especially should probably be done on changelogs. A lot of the justification for the markdown linting rules is to remove ambiguity that can result in differences between markdown renderers - so if we decide to change what renderer we use to convert the md to html, we won't have unexpected problems rendering these old docs. We can consider whether the language linting should affect historic changelogs when we deal with the separate issue. @maxime-rainville can you please just let us know if you're okay with us changing the old changelogs as they pertain to markdown, js, and php linting? |
@GuySartorelli I'm absolutely fine with updating old change log. I don't think of them as an "historical record". If something happens later on that alters the context of the changelog, I have no problem with pushing updates to them. |
94c133d
to
765c099
Compare
ce3f414
to
9b682e5
Compare
@emteknetnz Looks like you didn't look at this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My main things
- For file names for code fences, they should be bold above code fence, not in it the code fence
- Remove empty namespaces from php files
- There's a fair number capitilisation problems, this could get really annoying if failing builds because of it and cannot merge because the linter has got it wrong
@@ -698,16 +694,26 @@ time. | |||
For example, suppose we have the following set of classes: | |||
|
|||
```php | |||
use SilverStripe\CMS\Model\SiteTree; | |||
namespace { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These empty namespaces are pointless, can we simply not have them if there isn't one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They aren't pointless. They're required to pass linting, and they're also reflective of how the Page
and PageController
classes are declared in the recipe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, lots of people in bespoke say they just delete the redundant namespace since it indents everything. We should update those files in the recipe
They're required to pass linting
Then seems like we should make an exception in linting rather than enforcing an annoying standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's an annoying standard? It matches what our recipes have, and it is best practice to leave these in. If bespoke choose to remove them, that's up to them. I argue that it isn't redundant, it's explicit - and being explicit is good.
Basically, I think that if we're going to add an exception here, then we should also remove the namespace block from the recipe - and I don't think we should remove the namespace block from the recipe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I've been ignoring those namespace
statement for the last 5+ years and never bothered to check what their purpose was.
Are they there to get around the fact PSR-4 would want Page to be in a namespace, but Page needs to be in the root namespace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what they're there for in the recipe - but they're there. If we're removing them we should remove them from the recipe. If we're not removing them from the recipe we should keep them in the docs.
Currently they're in the recipe, so it makes sense to put them in the docs in this PR. Removing them should be a separate card, if that's what we decide we want to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say delete from recipe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to track down when we added those namespace
statement. That's what I found silverstripe/recipe-cms#11 (comment)
Doesn't look like there was much thought that went into this.
We also have this old RFC which doesn't look like it ever got implemented. silverstripe/silverstripe-framework#5844
In the interest of moving this along, I suggest we leave the namespace
statement in the doc. For now, if someone cares deeply about removing the namespace
statement, raise a separate card.
en/02_Developer_Guides/11_Integration/How_Tos/custom_csvbulkloader.md
Outdated
Show resolved
Hide resolved
'SpielerNummer' => 'PlayerNumber', | ||
] | ||
|
||
$this->$relationCallbacks = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two look wrong again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
I'll leave discussion about this in #387 (comment)
Do you mean there are some
I'm assuming you pointed those out in the review. If you didn't, please do so or I won't know what to fix. |
981abdb
to
3267197
Compare
Squashed all commits that update the documentation, because I accidentally adding linting changes to one of the non-linting doc change commits. |
I mean the instances where it has
I pointed out several in the peer review, though I've probably missed loads because of the sheer quantity of files changed. Most of these were 'sentance casing' classnames in headings. Some others so changing the casing of variables because they match a name in a list e.g. |
I really wish there was a way to reply to that type of comment directly on GitHub lol. Anyway: I think it's fine for us to have a few cases as a result of this PR where casing isn't 100% correct. We can fix them as we find them, but I don't think there will be many left since you and I have both put in some effort to find them already. In headings, it will be fairly obvious when looking at the docs that a classname was meant to have been surrounded in backticks, and the actual documentation below the heading will be correct regardless. In the
Existing examples have already been linted and are passing linting now. So it would only fail builds for any new documentation. From the examples you found, and the examples I had found while fixing the issues initially, it's basically only wrong when someone forgets backticks. So for new documentation, if it says "the casing is wrong", it's usually going to be a reminder to us that we should be adding backticks. I really don't think this is as big a problem as you're thinking. |
Yeah that's my point, for instance I write a heading |
Yes. And as I said:
i.e. you would see the linting failure, and update your PR to have |
OK cool. So what will happen if we put a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last two point seem very minor to me.
I generally fall in the "avoid disabling linting rules" camp... especially when those rules are coming from some central source.
If there's still disagreement about this, maybe we have a quick 15 min catch up to go through it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've opined on all the outstanding points that were controversial.
Also add editorconfig
DOC Document linting documentation DOC Document how to include filenames for code blocks
3267197
to
f74cb4b
Compare
NOTES
DO NOT SQUASH COMMITS
Issue