diff --git a/.eslintrc.yml b/.eslintrc.yml index dc10abaada..08991bdc34 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -147,6 +147,9 @@ rules: simple-import-sort/imports: - error - groups: + # Node.js builtin modules + - ["^node:\\w"] + # Packages. # Things that start with a letter (or digit or underscore), or `@` followed by a letter. - ["^@?\\w"] @@ -668,8 +671,9 @@ overrides: node: true rules: node/no-sync: off - node/no-unpublished-require: [error, { allowModules: ['mocha'] }] + node/no-unpublished-import: [error, { allowModules: ['mocha'] }] import/no-extraneous-dependencies: [error, { devDependencies: true }] + import/no-namespace: off import/no-nodejs-modules: off - files: 'integrationTests/*/**' parserOptions: diff --git a/integrationTests/integration-test.js b/integrationTests/integration-test.ts similarity index 79% rename from integrationTests/integration-test.js rename to integrationTests/integration-test.ts index 4565c71047..95e20a3bc7 100644 --- a/integrationTests/integration-test.js +++ b/integrationTests/integration-test.ts @@ -1,18 +1,16 @@ -'use strict'; +import * as childProcess from 'node:child_process'; +import * as fs from 'node:fs'; +import * as os from 'node:os'; +import * as path from 'node:path'; -const os = require('os'); -const fs = require('fs'); -const path = require('path'); -const childProcess = require('child_process'); +import { describe, it } from 'mocha'; -const { describe, it } = require('mocha'); - -function exec(command, options = {}) { +function exec(command: string, options = {}) { const output = childProcess.execSync(command, { encoding: 'utf-8', ...options, }); - return output && output.trimEnd(); + return output?.trimEnd(); } describe('Integration Tests', () => { @@ -27,7 +25,7 @@ describe('Integration Tests', () => { path.join(tmpDir, 'graphql.tgz'), ); - function testOnNodeProject(projectName) { + function testOnNodeProject(projectName: string) { const projectPath = path.join(__dirname, projectName); const packageJSONPath = path.join(projectPath, 'package.json'); diff --git a/package.json b/package.json index 309638d730..f4e1d8ac27 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "prettier": "prettier --write --list-different .", "prettier:check": "prettier --check .", "check:spelling": "cspell --cache --no-progress '**/*'", - "check:integrations": "npm run build:npm && npm run build:deno && mocha --full-trace integrationTests/*-test.js", + "check:integrations": "npm run build:npm && npm run build:deno && mocha --full-trace integrationTests/*-test.ts", "start": "DOCUSAURUS_GENERATED_FILES_DIR_NAME=\"$(pwd)/.docusaurus\" docusaurus start ./website", "build:website": "DOCUSAURUS_GENERATED_FILES_DIR_NAME=\"$(pwd)/.docusaurus\" docusaurus build --out-dir=\"$(pwd)/websiteDist\" ./website", "build:npm": "node resources/build-npm.js", diff --git a/tsconfig.json b/tsconfig.json index 059762a7b7..0508d36b18 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["src/**/*"], + "include": ["src/**/*", "integrationTests/*"], "compilerOptions": { "lib": ["es2020"], "target": "es2020",