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

Add TypeScript types #12

Merged
merged 5 commits into from
Apr 6, 2020
Merged

Add TypeScript types #12

merged 5 commits into from
Apr 6, 2020

Conversation

remcohaszing
Copy link
Member

@ChristianMurphy ChristianMurphy added ☂️ area/types This affects typings 🦋 type/enhancement This is great to have 🧑 semver/major This is a change labels Apr 1, 2020
Copy link
Member

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

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

Thanks @remcohaszing! 🙇‍♂️
Welcome the Unified! Glad to have you here! 👋
Skimming the changes this looks generally good.
A few tweaks that could help with reviewing:

  1. could .ts files be included in the types of files prettier formats? (in the format script in package.json)
  2. could dtslint be added to validate the typings?
  3. could a types test file be added with some example uses of the plugin in TypeScript?

A recent PR made to remark-toc gives an example of most of these remarkjs/remark-toc#29

- Change prettier glob to current directory
- Add `*.md` to `.prettierignore`, since it wasn’t formatted.
- Format code using Prettier.
- Add TypeScript tests.
- Add dtslint.
@codecov-io

This comment has been minimized.

@remcohaszing
Copy link
Member Author

Thanks for the quick feedback!

I did the following:

  • Change prettier glob to current directory
  • Add *.md to .prettierignore, since it wasn’t formatted.
  • Format code using Prettier.
  • Add TypeScript tests.
  • Add dtslint.

xo --fix fails now. I’m not familiar with xo, but I am confused how it is used here. The TypeScript code is linted using both dtslint and xo, which uses @typescript-eslint under the hood. These rules might even conflict, but I can’t verify this, since xo throws:

Error: Error while loading rule '@typescript-eslint/await-thenable': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Occurred while linting /home/remco/Projects/remark-frontmatter/types/remark-frontmatter-tests.ts
    at Object.getParserServices (/home/remco/Projects/remark-frontmatter/node_modules/@typescript-eslint/experimental-utils/dist/eslint-utils/getParserServices.js:15:15)
    at create (/home/remco/Projects/remark-frontmatter/node_modules/@typescript-eslint/eslint-plugin/dist/rules/await-thenable.js:30:37)
    at Object.create (/home/remco/Projects/remark-frontmatter/node_modules/@typescript-eslint/experimental-utils/dist/eslint-utils/RuleCreator.js:12:24)
    at createRuleListeners (/home/remco/Projects/remark-frontmatter/node_modules/eslint/lib/linter/linter.js:746:21)
    at /home/remco/Projects/remark-frontmatter/node_modules/eslint/lib/linter/linter.js:916:31
    at Array.forEach (<anonymous>)
    at runRules (/home/remco/Projects/remark-frontmatter/node_modules/eslint/lib/linter/linter.js:861:34)
    at Linter._verifyWithoutProcessors (/home/remco/Projects/remark-frontmatter/node_modules/eslint/lib/linter/linter.js:1157:31)
    at Linter._verifyWithoutProcessors (/home/remco/Projects/remark-frontmatter/node_modules/eslint-plugin-eslint-comments/lib/utils/patch.js:165:42)
    at Linter._verifyWithConfigArray (/home/remco/Projects/remark-frontmatter/node_modules/eslint/lib/linter/linter.js:1255:21)

@ChristianMurphy
Copy link
Member

I haven't run into that specific error, but on other repo's I've run into random errors with xo and the type definitions.
adding --ignore types to the XO options seems to do the trick.

Copy link
Member

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

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

Thanks @remcohaszing !

@wooorm wooorm merged commit 65b8410 into remarkjs:master Apr 6, 2020
@wooorm
Copy link
Member

wooorm commented Apr 6, 2020

Released in 2.0.0. Thanks @remcohaszing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☂️ area/types This affects typings 💪 phase/solved Post is done 🧑 semver/major This is a change 🦋 type/enhancement This is great to have
Development

Successfully merging this pull request may close these issues.

5 participants