Skip to content
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

Merged
merged 4 commits into from Aug 12, 2019
Merged

Conversation

twhid
Copy link
Contributor

@twhid twhid commented Aug 5, 2019

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

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
@twhid twhid requested a review from hellatan August 5, 2019 23:09
@twhid twhid self-assigned this Aug 5, 2019
@twhid twhid requested a review from robrichard August 5, 2019 23:09
"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"
Copy link
Contributor

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",
Copy link
Contributor

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'],
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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',
            },
        },
    ],
};

Copy link
Contributor

@hellatan hellatan Aug 9, 2019

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. One file.

@twhid
Copy link
Contributor Author

twhid commented Aug 9, 2019

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.

@twhid twhid merged commit dca4055 into master Aug 12, 2019
@twhid twhid deleted the typescript+eslint-prettier branch August 12, 2019 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants