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

WIP - Upgrade to ESLint 9 #168

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 1 addition & 29 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,7 @@ module.exports = {
sourceType: 'module',
},

rules: {
// This makes integration tests easier to read by allowing setup code and
// assertions to be grouped together better
'padding-line-between-statements': [
'error',
{
blankLine: 'always',
prev: 'directive',
next: '*',
},
{
blankLine: 'any',
prev: 'directive',
next: 'directive',
},
{
blankLine: 'always',
prev: 'multiline-block-like',
next: '*',
},
{
blankLine: 'always',
prev: '*',
next: 'multiline-block-like',
},
],
// It's common for scripts to access `process.env`
'node/no-process-env': 'off',
},
rules: {},

overrides: [
{
Expand Down
6 changes: 3 additions & 3 deletions babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
env: {
test: {
presets: ['@babel/preset-env', '@babel/preset-typescript'],
plugins: ['@babel/plugin-transform-modules-commonjs']
}
}
plugins: ['@babel/plugin-transform-modules-commonjs'],
},
},
};
76 changes: 76 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import base, { createConfig } from '@metamask/eslint-config';
import jest from '@metamask/eslint-config-jest';
import nodejs from '@metamask/eslint-config-nodejs';
import typescript from '@metamask/eslint-config-typescript';

const config = createConfig([
{
ignores: ['dist/', 'docs/', '.yarn/'],
},

{
extends: [base, nodejs],

languageOptions: {
sourceType: 'module',
parserOptions: {
tsconfigRootDir: import.meta.dirname,
project: ['./tsconfig.json'],
},
},

settings: {
'import-x/extensions': ['.js', '.mjs'],
},

rules: {
// This makes integration tests easier to read by allowing setup code and
// assertions to be grouped together better
'padding-line-between-statements': [
'error',
{
blankLine: 'always',
prev: 'directive',
next: '*',
},
{
blankLine: 'any',
prev: 'directive',
next: 'directive',
},
{
blankLine: 'always',
prev: 'multiline-block-like',
next: '*',
},
{
blankLine: 'always',
prev: '*',
next: 'multiline-block-like',
},
],
// It's common for scripts to access `process.env`
'node/no-process-env': 'off',
},
},

{
files: ['**/*.ts'],
extends: typescript,
},

{
files: ['**/*.js', '**/*.cjs'],

languageOptions: {
sourceType: 'script',
},
},

{
files: ['**/*.test.ts', '**/*.test.js'],
extends: [jest, nodejs],
},
]);

export default config;
2 changes: 1 addition & 1 deletion jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ module.exports = {

// A map from regular expressions to paths to transformers
transform: {
"\\.[jt]sx?$": "babel-jest"
'\\.[jt]sx?$': 'babel-jest',
},

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
Expand Down
34 changes: 19 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build": "tsc --project tsconfig.build.json",
"build:clean": "rimraf dist && yarn build",
"lint": "yarn lint:eslint && yarn lint:misc --check",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:eslint": "eslint . --cache",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' '!.yarnrc.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern",
"prepack": "./scripts/prepack.sh",
Expand All @@ -43,10 +43,10 @@
"@babel/preset-env": "^7.23.5",
"@babel/preset-typescript": "^7.23.3",
"@lavamoat/allow-scripts": "^3.1.0",
"@metamask/eslint-config": "^10.0.0",
"@metamask/eslint-config-jest": "^10.0.0",
"@metamask/eslint-config-nodejs": "^10.0.0",
"@metamask/eslint-config-typescript": "^10.0.0",
"@metamask/eslint-config": "^14.0.0",
"@metamask/eslint-config-jest": "^14.0.0",
"@metamask/eslint-config-nodejs": "^14.0.0",
"@metamask/eslint-config-typescript": "^14.0.0",
"@types/debug": "^4.1.7",
"@types/jest": "^29.5.10",
"@types/jest-when": "^3.5.2",
Expand All @@ -56,27 +56,31 @@
"@types/validate-npm-package-name": "^4.0.2",
"@types/which": "^3.0.0",
"@types/yargs": "^17.0.10",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@typescript-eslint/eslint-plugin": "^8.25.0",
"@typescript-eslint/parser": "^8.25.0",
"babel-jest": "^29.7.0",
"deepmerge": "^4.2.2",
"eslint": "^8.27.0",
"eslint": "^9.21.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.9.0",
"eslint-plugin-jsdoc": "^39.6.2",
"eslint-import-resolver-typescript": "^3.8.3",
"eslint-plugin-import-x": "^4.6.1",
"eslint-plugin-jest": "^28.11.0",
"eslint-plugin-jsdoc": "^50.6.3",
"eslint-plugin-n": "^17.15.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-promise": "^7.2.1",
"jest": "^29.7.0",
"jest-it-up": "^3.0.0",
"jest-when": "^3.5.2",
"nanoid": "^3.3.4",
"prettier": "^3.3.3",
"prettier-plugin-packagejson": "^2.5.2",
"prettier": "^3.5.2",
"prettier-plugin-packagejson": "^2.5.8",
"rimraf": "^4.0.5",
"stdio-mock": "^1.2.0",
"tsx": "^4.6.1",
"typescript": "~5.1.6"
"typescript": "~5.1.6",
"typescript-eslint": "^8.25.0"
},
"peerDependencies": {
"prettier": ">=3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/command-line-arguments.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import yargs from 'yargs/yargs';
import { hideBin } from 'yargs/helpers';
import yargs from 'yargs/yargs';

export type CommandLineArguments = {
projectDirectory: string;
Expand Down
1 change: 1 addition & 0 deletions src/editor.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { when } from 'jest-when';

import { determineEditor } from './editor.js';
import * as envModule from './env.js';
import * as miscUtils from './misc-utils.js';
Expand Down
5 changes: 3 additions & 2 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
/**
* Information about the editor present on the user's computer.
*
* @property path - The path to the executable representing the editor.
* @property args - Command-line arguments to pass to the executable when
* path - The path to the executable representing the editor.
*
* args - Command-line arguments to pass to the executable when
* calling it.
*/
export type Editor = {
Expand All @@ -31,7 +32,7 @@
executablePath = await resolveExecutable(EDITOR);
} catch (error) {
debug(
`Could not resolve executable ${EDITOR} (${error}), falling back to VSCode`,

Check failure on line 35 in src/editor.ts

View workflow job for this annotation

GitHub Actions / Lint (18.x)

Invalid type "unknown" of template literal expression

Check failure on line 35 in src/editor.ts

View workflow job for this annotation

GitHub Actions / Lint (20.x)

Invalid type "unknown" of template literal expression
);
}
}
Expand All @@ -43,7 +44,7 @@
executableArgs.push('--wait');
} catch (error) {
debug(
`Could not resolve path to VSCode: ${error}, continuing regardless`,

Check failure on line 47 in src/editor.ts

View workflow job for this annotation

GitHub Actions / Lint (18.x)

Invalid type "unknown" of template literal expression

Check failure on line 47 in src/editor.ts

View workflow job for this annotation

GitHub Actions / Lint (20.x)

Invalid type "unknown" of template literal expression
);
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/fs.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as actionUtils from '@metamask/action-utils';
import fs from 'fs';
import { when } from 'jest-when';
import path from 'path';
import { rimraf } from 'rimraf';
import { when } from 'jest-when';
import * as actionUtils from '@metamask/action-utils';
import { withSandbox } from '../tests/helpers.js';

import {
readFile,
writeFile,
Expand All @@ -13,6 +13,7 @@ import {
ensureDirectoryPathExists,
removeFile,
} from './fs.js';
import { withSandbox } from '../tests/helpers.js';

jest.mock('@metamask/action-utils');

Expand Down
3 changes: 2 additions & 1 deletion src/fs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import fs from 'fs';
import {
readJsonObjectFile as underlyingReadJsonObjectFile,
writeJsonFile as underlyingWriteJsonFile,
} from '@metamask/action-utils';
import fs from 'fs';

import { wrapError, isErrorWithCode } from './misc-utils.js';

/**
Expand Down
11 changes: 6 additions & 5 deletions src/initial-parameters.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { when } from 'jest-when';
import os from 'os';
import path from 'path';
import { when } from 'jest-when';

import * as commandLineArgumentsModule from './command-line-arguments.js';
import * as envModule from './env.js';
import { determineInitialParameters } from './initial-parameters.js';
import * as projectModule from './project.js';
import {
buildMockProject,
buildMockPackage,
createNoopWriteStream,
} from '../tests/unit/helpers.js';
import { determineInitialParameters } from './initial-parameters.js';
import * as commandLineArgumentsModule from './command-line-arguments.js';
import * as envModule from './env.js';
import * as projectModule from './project.js';

jest.mock('./command-line-arguments');
jest.mock('./env');
Expand Down
6 changes: 4 additions & 2 deletions src/initial-parameters.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os from 'os';
import path from 'path';

import { readCommandLineArguments } from './command-line-arguments.js';
import { WriteStreamLike } from './fs.js';
import { readProject, Project } from './project.js';
import type { WriteStreamLike } from './fs.js';
import type { Project } from './project.js';
import { readProject } from './project.js';

/**
* The type of release being created as determined by the parent release.
Expand Down
5 changes: 3 additions & 2 deletions src/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import fs from 'fs';
import { buildMockProject } from '../tests/unit/helpers.js';
import { main } from './main.js';

import * as initialParametersModule from './initial-parameters.js';
import { main } from './main.js';
import * as monorepoWorkflowOperations from './monorepo-workflow-operations.js';
import { buildMockProject } from '../tests/unit/helpers.js';

jest.mock('./initial-parameters');
jest.mock('./monorepo-workflow-operations');
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { WriteStream } from 'fs';

import { determineInitialParameters } from './initial-parameters.js';
import { followMonorepoWorkflow } from './monorepo-workflow-operations.js';

Expand All @@ -14,7 +15,7 @@
* @param args.stdout - A stream that can be used to write to standard out.
* @param args.stderr - A stream that can be used to write to standard error.
*/
export async function main({

Check failure on line 18 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint (18.x)

Missing return type on function

Check failure on line 18 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint (20.x)

Missing return type on function
argv,
cwd,
stdout,
Expand Down
3 changes: 2 additions & 1 deletion src/misc-utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as whichModule from 'which';
import * as execaModule from 'execa';
import * as whichModule from 'which';

import {
isErrorWithCode,
isErrorWithMessage,
Expand Down
7 changes: 4 additions & 3 deletions src/misc-utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import which from 'which';
import { execa, Options } from 'execa';
import { isObject } from '@metamask/utils';
import createDebug from 'debug';
import type { Options } from 'execa';
import { execa } from 'execa';
import { ErrorWithCause } from 'pony-cause';
import { isObject } from '@metamask/utils';
import which from 'which';

export { isTruthyString } from '@metamask/action-utils';
export { hasProperty, isNullOrUndefined } from '@metamask/utils';
Expand Down
17 changes: 10 additions & 7 deletions src/monorepo-workflow-operations.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import fs from 'fs';
import path from 'path';
import { when } from 'jest-when';
import path from 'path';
import { MockWritable } from 'stdio-mock';
import { withSandbox, Sandbox, isErrorWithCode } from '../tests/helpers';
import { buildMockProject, Require } from '../tests/unit/helpers';
import { followMonorepoWorkflow } from './monorepo-workflow-operations.js';

import * as editorModule from './editor.js';
import type { Editor } from './editor.js';
import * as releaseSpecificationModule from './release-specification.js';
import type { ReleaseSpecification } from './release-specification.js';
import { followMonorepoWorkflow } from './monorepo-workflow-operations.js';
import * as releasePlanModule from './release-plan.js';
import type { ReleasePlan } from './release-plan.js';
import * as releaseSpecificationModule from './release-specification.js';
import type { ReleaseSpecification } from './release-specification.js';
import * as repoModule from './repo.js';
import * as yarnCommands from './yarn-commands.js';
import * as workflowOperations from './workflow-operations.js';
import * as yarnCommands from './yarn-commands.js';
import { withSandbox, isErrorWithCode } from '../tests/helpers';
import type { Sandbox } from '../tests/helpers';
import { buildMockProject } from '../tests/unit/helpers';
import type { Require } from '../tests/unit/helpers';

jest.mock('./editor');
jest.mock('./release-plan');
Expand Down
9 changes: 5 additions & 4 deletions src/monorepo-workflow-operations.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import type { WriteStream } from 'fs';
import path from 'path';

import { determineEditor } from './editor.js';
import {
ensureDirectoryPathExists,
fileExists,
removeFile,
writeFile,
} from './fs.js';
import { determineEditor } from './editor.js';
import { ReleaseType } from './initial-parameters.js';
import type { ReleaseType } from './initial-parameters.js';
import type { Project } from './project.js';
import {
Project,
updateChangelogsForChangedPackages,
restoreChangelogsForSkippedPackages,
} from './project.js';
import { planRelease, executeReleasePlan } from './release-plan.js';
import { commitAllChanges } from './repo.js';
import {
generateReleaseSpecificationTemplateForMonorepo,
waitForUserToEditReleaseSpecification,
validateReleaseSpecification,
} from './release-specification.js';
import { commitAllChanges } from './repo.js';
import { createReleaseBranch } from './workflow-operations.js';
import {
deduplicateDependencies,
Expand Down
Loading
Loading