-
Notifications
You must be signed in to change notification settings - Fork 12
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
streamline TS; prettier via eslint #60
Conversation
Two main changes in this PR: 1. TS incorporated into 1 eslint config. This allows consumers to use overrides to target ts-only files 2. prettier is run via eslint. This allows more streamlined eslint commands for ci and precommit hooks Also, only load flowtype rules for js(x) files
"eslint-plugin-jest": "^22.5.1" | ||
"eslint-plugin-jest": "^22.5.1", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"prettier": "^1.18.2" | ||
}, | ||
"peerDependencies": { | ||
"eslint": ">=5.16.0 <6" |
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 you have to update the peerDeps here if you're introducing version 6. Not sure why I did this range style instead of just the caret.
@@ -11,6 +11,8 @@ | |||
}, | |||
"devDependencies": { | |||
"dibs-prettier-config": "^1.4.2", | |||
"eslint": "^6.1.0", |
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.
This is marked as a dev/peerDep in the individual packages. You'll need to update those references as well.
@@ -1,11 +1,27 @@ | |||
module.exports = { | |||
plugins: ['@typescript-eslint/eslint-plugin'], |
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.
You can't combine this file and the index file?
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 play around with it a bit more.
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.
Perhaps I'm simply not up-to-date on how overrides
work vis a vis extends
, but when I add the typescript override to the index file, I get an assertion error from eslint. There's an issue open on the eslint repo that seems to be relevant to the error I'm running into.
So, the way I worked around that was to create a typescript file and the consumer needs to add an override, ie:
module.exports = {
extends: ['eslint-config-1stdibs'],
overrides: [
{
files: ['*.{ts,tsx}'],
extends: ['eslint-config-1stdibs/typescript'].map(require.resolve),
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
},
],
};
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 consumers will have one .eslintrc file then?
Do you need the require.resolve
in the override section even if it's in the consumer?
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.
Yup. One file.
I've updated dev and peer deps everywhere to make eslint's version consistent. I'll update with release versions once everyone agrees on the changes in the private repo consuming this package. |
Two main changes in this PR:
Also, only load flowtype rules for js(x) files