Skip to content

Commit

Permalink
Add missing import extension, check with lint (#4795)
Browse files Browse the repository at this point in the history
Some pure-ESM processors (eg, `tsc` with `moduleResolution: 'nodenext')
require extensions on all imports. #4778 added two import-less
extensions. This PR fixes them and adds linting (from an
already-installed plugin) to catch future errors. Test execution does
not appear to require these extensions so we only check non-test files
(there's another 17 errors to fix if you want to check tests too).
  • Loading branch information
glasser authored Oct 29, 2022
1 parent 0f149dc commit f7daf77
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/short-melons-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/utils': patch
---

Fix build break in v8.13.0 in some ESM environments.
18 changes: 16 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ module.exports = {
parserOptions: {
project: './tsconfig.json',
},
extends: ['eslint:recommended', 'standard', 'prettier', 'plugin:@typescript-eslint/recommended'],
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'standard',
'prettier',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
],
plugins: ['@typescript-eslint', 'import'],
rules: {
'no-empty': 'off',
'no-console': 'off',
Expand Down Expand Up @@ -94,6 +100,14 @@ module.exports = {
'promise/param-names': 'off',
},
},
{
// Require extensions on all imports (other than package imports) outside
// of tests, as some ESM environments expect this when loading files.
// We don't check tests because they don't get compiled into the packages.
files: ['**/*.ts'],
excludedFiles: ['**/{test,tests,testing}/**/*.{ts,js}', '*.{spec,test}.{ts,js}'],
rules: { 'import/extensions': ['error', 'ignorePackages'] },
},
],
ignorePatterns: [
'dist',
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/Path.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Maybe } from './types';
import { Maybe } from './types.js';

export interface Path {
readonly prev: Path | undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/jsutils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MaybePromise } from './executor';
import { MaybePromise } from './executor.js';

export function isIterableObject(value: unknown): value is Iterable<unknown> {
return value != null && typeof value === 'object' && Symbol.iterator in value;
Expand Down

0 comments on commit f7daf77

Please sign in to comment.