-
Notifications
You must be signed in to change notification settings - Fork 536
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
Convert @fluid-example/table-document tests to use esnext modules #15939
Conversation
⯅ @fluid-example/bundle-size-tests: +30 Bytes
Baseline commit: 1f97dff |
// ESLint's resolver doesn't resolve relative imports of ESNext modules correctly, since | ||
// it resolves the path relative to the .ts file (and assumes a file with a .js extension | ||
// should exist there) | ||
"import/no-unresolved": ["error", { ignore: ["^\\.(.*)\\.js$"] }], |
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 love to make eslint's module resolver understand these imports, but I'm not sure it's possible out of the box (we'd have to maintain our own resolver, and I'm not sure if it would be a trivial wrapper over the base node resolver or not). I don't think this rule provides particularly high value for relative imports though, so IMO it's not the worst.
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.
Someone must have written a solution for this already, right? Typescript transpiled to a different folder + ESM should be a common scenario by now...? Can be addressed separately.
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 prodding me to look into this again. I think we can actually make this work nicely by removing eslint-plugin-unused-imports, transitioning to eslint-plugin-import, and updating our import resolve to be eslint-import-resolver-typescript (where the default extensionAlias
should work perfectly). that'll require a release of the common lint config, though.
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.
overrides: [ | ||
{ | ||
// Rules only for test files | ||
files: ["*.spec.ts", "src/test/**"], |
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.
Nit. There should be no *.spec.ts
files outside src/test/
anyway, right? Not 100% sure about the glob syntax, if it's incorrect then just keep src/test/**
?
files: ["*.spec.ts", "src/test/**"], | |
files: ["src/test/**/*.spec.ts"], |
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.
seems like we use this glob in basically all our other packages with "test-only overrides". i'd prefer to keep that consistent over some simplification. We do want non-.spec files inside the test-folder to be exempted as well though, so if we were to change it, it should be src/test/**
// ESLint's resolver doesn't resolve relative imports of ESNext modules correctly, since | ||
// it resolves the path relative to the .ts file (and assumes a file with a .js extension | ||
// should exist there) | ||
"import/no-unresolved": ["error", { ignore: ["^\\.(.*)\\.js$"] }], |
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.
Someone must have written a solution for this already, right? Typescript transpiled to a different folder + ESM should be a common scenario by now...? Can be addressed separately.
…crosoft#15939) ## Description This makes progress toward microsoft#15917 by converting `@fluid-example/table-document`'s tests to run esnext modules only. It's not yet feasible to convert the whole package to esnext, as despite being an example package it's currently used by some internal partners. I've therefore just converted the test config to use esnext.
## Description #15939 and related PRs disabled this linter rule for imports to `.js` files, since the base eslint module resolver doesn't understand that relative imports to .js should sometimes conceptually refer to .ts files instead. This re-enables linting for that rule in affected packages by using [eslint-import-resolver-typescript](https://www.npmjs.com/package/eslint-import-resolver-typescript).
## Description #15939 and related PRs disabled this linter rule for imports to `.js` files, since the base eslint module resolver doesn't understand that relative imports to .js should sometimes conceptually refer to .ts files instead. This re-enables linting for that rule in affected packages by using [eslint-import-resolver-typescript](https://www.npmjs.com/package/eslint-import-resolver-typescript).
Description
This makes progress toward #15917 by converting
@fluid-example/table-document
's tests to run esnext modules only.It's not yet feasible to convert the whole package to esnext, as despite being an example package it's currently used by some internal partners. I've therefore just converted the test config to use esnext.