Skip to content

Commit

Permalink
Align ESLint, Prettier packages and configs with core monorepo ahead …
Browse files Browse the repository at this point in the history
…of migration (#28)

## Description
- This PR aligns the ESLint and Prettier packages and configs in this repo with the core monorepo.
- This is a preparation step for migrating the `eth-json-rpc-provider` package into the core monorepo.
- Originally, the plan was to decrement the TypeScript version to align with the core monorepo, but following [this discussion](MetaMask/eth-json-rpc-provider#27), we've opted to use TypeScript version v4.8.4, and preserve the compiler options in this package that aren't enabled in the core monorepo.

## References
- See #1551
- Closes #1683
- Closes #1682 (is superseded by this PR)
  • Loading branch information
MajorLift authored Sep 28, 2023
1 parent 0aa45a9 commit db9598b
Show file tree
Hide file tree
Showing 4 changed files with 1,233 additions and 825 deletions.
137 changes: 118 additions & 19 deletions merged-packages/eth-json-rpc-provider/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,135 @@
module.exports = {
root: true,

extends: ['@metamask/eslint-config'],

extends: ['@metamask/eslint-config', '@metamask/eslint-config-nodejs'],
ignorePatterns: [
'!.eslintrc.js',
'!jest.config.js',
'node_modules',
'dist',
'docs',
'coverage',
// 'merged-packages',
],
overrides: [
{
files: ['*.ts'],
extends: ['@metamask/eslint-config-typescript'],
files: ['*.test.{ts,js}', '**/tests/**/*.{ts,js}'],
extends: ['@metamask/eslint-config-jest'],
rules: {
// TODO: Re-enable
'import/no-named-as-default-member': 'off',
'jest/no-conditional-expect': 'off',
},
},
{
// These files are test helpers, not tests. We still use the Jest ESLint
// config here to ensure that ESLint expects a test-like environment, but
// various rules meant just to apply to tests have been disabled.
files: ['**/tests/**/*.{ts,js}', '!*.test.{ts,js}'],
rules: {
'jest/no-export': 'off',
'jest/require-top-level-describe': 'off',
'jest/no-if': 'off',
'jest/no-test-return-statement': 'off',
// TODO: Re-enable this rule; we can accomodate this even in our test helpers
'jest/expect-expect': 'off',
},
},

{
files: ['*.js'],
parserOptions: {
sourceType: 'script',
ecmaVersion: '2018',
},
extends: ['@metamask/eslint-config-nodejs'],
},
{
files: ['*.ts'],
extends: ['@metamask/eslint-config-typescript'],
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
rules: {
// disabled due to incompatibility with Record<string, unknown>
// See https://github.com/Microsoft/TypeScript/issues/15300#issuecomment-702872440
'@typescript-eslint/consistent-type-definitions': 'off',

// TODO: auto-fix breaks stuff
'@typescript-eslint/promise-function-async': 'off',

// TODO: re-enble most of these rules
'@typescript-eslint/await-thenable': 'warn',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-for-in-array': 'warn',
'@typescript-eslint/no-loss-of-precision': 'warn',
'@typescript-eslint/no-misused-promises': 'warn',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/prefer-enum-initializers': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-reduce-type-parameter': 'off',
'@typescript-eslint/restrict-plus-operands': 'warn',
'@typescript-eslint/restrict-template-expressions': 'warn',
'no-restricted-syntax': 'off',
'no-restricted-globals': 'off',
},
},
{
files: ['tests/setupAfterEnv/matchers.ts'],
parserOptions: {
sourceType: 'script',
},
},
{
files: ['*.test.ts', '*.test.js'],
extends: [
'@metamask/eslint-config-jest',
'@metamask/eslint-config-nodejs',
],
files: ['*.d.ts'],
rules: {
'@typescript-eslint/naming-convention': 'warn',
'import/unambiguous': 'off',
},
},
{
files: ['scripts/*.ts'],
rules: {
// All scripts will have shebangs.
'n/shebang': 'off',
},
},
],
rules: {
// Left disabled because various properties throughough this repo are snake_case because the
// names come from external sources or must comply with standards
// e.g. `txreceipt_status`, `signTypedData_v4`, `token_id`
camelcase: 'off',
'id-length': 'off',

ignorePatterns: [
'!.eslintrc.js',
'!.prettierrc.js',
'dist/',
'docs/',
'.yarn/',
],
// TODO: re-enble most of these rules
'@typescript-eslint/naming-convention': 'off',
'function-paren-newline': 'off',
'guard-for-in': 'off',
'id-denylist': 'off',
'implicit-arrow-linebreak': 'off',
'import/no-anonymous-default-export': 'off',
'import/no-unassigned-import': 'off',
'lines-around-comment': 'off',
'n/no-sync': 'off',
'no-async-promise-executor': 'off',
'no-case-declarations': 'off',
'no-invalid-this': 'off',
'no-negated-condition': 'off',
'no-new': 'off',
'no-param-reassign': 'off',
'no-restricted-syntax': 'off',
radix: 'off',
'require-atomic-updates': 'off',
'jsdoc/match-description': [
'off',
{ matchDescription: '^[A-Z`\\d_][\\s\\S]*[.?!`>)}]$' },
],
},
settings: {
'import/resolver': {
typescript: {},
},
},
};
30 changes: 16 additions & 14 deletions merged-packages/eth-json-rpc-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,37 @@
"@metamask/utils": "^8.1.0"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^2.0.3",
"@lavamoat/allow-scripts": "^2.3.1",
"@metamask/auto-changelog": "^3.1.0",
"@metamask/eslint-config": "^11.0.1",
"@metamask/eslint-config-jest": "^11.0.0",
"@metamask/eslint-config-nodejs": "^11.0.1",
"@metamask/eslint-config-typescript": "^11.0.0",
"@metamask/eslint-config": "^12.2.0",
"@metamask/eslint-config-jest": "^12.0.0",
"@metamask/eslint-config-nodejs": "^12.0.0",
"@metamask/eslint-config-typescript": "^12.0.0",
"@types/jest": "^28.1.6",
"@types/node": "^16.18.39",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
"@types/node": "^16.18.24",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.30.7",
"depcheck": "^1.4.3",
"eslint": "^8.27.0",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.5",
"eslint-plugin-jsdoc": "^39.6.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-jsdoc": "^39.3.3",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"jest": "^28.1.3",
"jest-it-up": "^2.0.2",
"prettier": "^2.7.1",
"prettier-plugin-packagejson": "^2.3.0",
"prettier-plugin-packagejson": "^2.2.17",
"rimraf": "^3.0.2",
"ts-jest": "^28.0.7",
"ts-node": "^10.7.0",
"ts-node": "^10.9.1",
"typedoc": "^0.23.15",
"typescript": "~4.8.4"
},
"packageManager": "yarn@3.2.1",
"packageManager": "yarn@3.3.0",
"engines": {
"node": "^16.20 || ^18.16 || >=20"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JsonRpcMiddleware } from '@metamask/json-rpc-engine';
import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine';
import { promisify } from 'util';

import { providerFromMiddleware } from './provider-from-middleware';
Expand Down
Loading

0 comments on commit db9598b

Please sign in to comment.