-
Notifications
You must be signed in to change notification settings - Fork 18
Conversation
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.
Thanks!
.eslintrc.js
Outdated
| @@ -0,0 +1,13 @@ | |||
| module.exports = { | |||
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.
Let's standardise how we do this across projects, like so:
// package.json
{
"scripts": {
"format": "prettier . --write",
"lint:formatting": "prettier . --check",
"lint:js": "eslint . --ignore-path .gitignore",
"lint": "npm-run-all --parallel lint:*",
"release": "np",
"test": "jest",
"watch": "jest --watch"
},
"eslintConfig": {
"extends": [
"stylelint"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js": "eslint --cache --fix",
"*.(js,md,yml}": "prettier --write"
}
}
Integrating Prettier into ESLints floods our editors with squiggly red lines for unimportant formatting issues.
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.
Thank you for your review!
I made this change.
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.
Thanks for adding the linting run-script commands.
Integrating Prettier into ESLint floods our editors with squiggly red lines for unimportant formatting issues.
Can you:
- replace
eslint-config-prettierwith anpm run formatcommand - move the eslint config into
package.json
So that it is consistent with the other stylelint repos.
Like so:
// package.json
{
"scripts": {
"format": "prettier . --write",
"lint:formatting": "prettier . --check",
"lint:js": "eslint . --ignore-path .gitignore",
"lint": "npm-run-all --parallel lint:*",
},
"eslintConfig": {
"extends": [
"stylelint"
],
parserOptions: {
ecmaVersion: 2019,
},
rules: {
'jest/valid-expect': 'off',
}
}
}
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 moved the eslint configuration to package.json.
However, eslint-config-prettier is required. This prevents conflict between prettier and eslint. Specifically, it conflicts with "no-mixed-spaces-and-tabs".
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.
Sorry, my bad. I mixed up the prettier plugin with the prettier config.
We should move eslint-config-prettier into eslint-config-stylelint, like we intend to do with the equivalent remark preset in @stylelint/remark-preset, as it's applicable to all stylelint repos.
We can do this in a follow-up pull request once we release a new version of eslint-config-stylelint, though.
| @@ -0,0 +1,23 @@ | |||
| 'use strict'; | |||
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 prefer we use Prettier without any settings as we offload any decision making to that team (see version Prettier 2 changes) and I don't believe there's an easy way to share a Prettier config across repos, which means we have to keep them in sync manually.
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 believe there's an easy way to share a Prettier config across repos
Scratch that: https://prettier.io/docs/en/configuration.html#sharing-configurations
If the general consensus is to define our own settings then let's pull them out into @stylelint/prettier-config and roll them out across the org. We can do that in a follow-up pull request, one that probably uses remark-preset-lint-stylelint too.
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.
Pull request pending at stylelint/prettier-config#1
| @@ -1,14 +1,18 @@ | |||
| *.log | |||
| *.pid | |||
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'll create a follow-up PR to move to a files: [] whitelisting approach.
jeddy3
left a comment
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.
Thanks for making changes. I've requested a follow-up one.
.eslintrc.js
Outdated
| @@ -0,0 +1,13 @@ | |||
| module.exports = { | |||
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.
Thanks for adding the linting run-script commands.
Integrating Prettier into ESLint floods our editors with squiggly red lines for unimportant formatting issues.
Can you:
- replace
eslint-config-prettierwith anpm run formatcommand - move the eslint config into
package.json
So that it is consistent with the other stylelint repos.
Like so:
// package.json
{
"scripts": {
"format": "prettier . --write",
"lint:formatting": "prettier . --check",
"lint:js": "eslint . --ignore-path .gitignore",
"lint": "npm-run-all --parallel lint:*",
},
"eslintConfig": {
"extends": [
"stylelint"
],
parserOptions: {
ecmaVersion: 2019,
},
rules: {
'jest/valid-expect': 'off',
}
}
}
jeddy3
left a comment
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.
Looking good. One request and one query.
.prettierrc.js
Outdated
| endOfLine: 'lf', | ||
| printWidth: 100, | ||
| singleQuote: true, | ||
| trailingComma: 'es5', |
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.
We use trailingComma: 'all' in the main repo. Which do we want to standardise on and use here (and in @stylelint/config-prettier)?
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.
Currently released eslint-config-stylelint uses ES6, so trailingComma of function argument cannot be used.
https://github.com/stylelint/eslint-config-stylelint/blob/11.1.0/eslintrc.js#L12
Specify ecmaVersion: 2019 in individual eslintConfig?
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.
Let's release a new version of eslint-config-stylelint with ecmaVersion: 2019.
In the meantime, let's offload the decision about trailing commas to Prettier and use their default (which as of version 2 is es5):
Change default value for trailingComma to es5
There is a possibility that the default value will change to always (meaning even more trailing commas) in a future major version of Prettier as the JavaScript ecosystem further matures.
Please remove trailingComma: 'es5' from this pull request and I'll remove trailingComma: 'all' from @stylelint/prettier-config.
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 have removed trailingComma from .prettierrc.
| ] | ||
| }, | ||
| "scripts": { | ||
| "lint:formatting": "prettier . --check", |
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.
We should add a "format": "prettier . --write", command for consistency with the other stylelint repos. Therefore, regardless of the underlying tool (for example, Jest or Mocha), the same main commands work across repositories: format, lint, test, watch, release.
|
I have made the changes you requested. |
jeddy3
left a comment
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.
Almost there. One last amend and I think the pull request is ready.
package.json
Outdated
| "lint:formatting": "prettier . --check", | ||
| "lint:js": "eslint .", | ||
| "lint": "npm-run-all --parallel lint:*", | ||
| "pretest": "npm run lint", |
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.
Let's remove the pretest lifecycle command and replace with a "lint" task, like so as we only want lint once on the CI. This will be consistent with other repositories.
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 removed the 'pretest' script and added lint to CI.
jeddy3
left a comment
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.
Thank you!
The CI looks great with one lint run and two test runs.
Close #12
This PR introduces linter and formatter to the repository.
@stylelint/prettier-configis released, use it.eslint-config-stylelintis released, use it.