Skip to content

Commit

Permalink
Use Eslint instead of Tslint (#1005)
Browse files Browse the repository at this point in the history
* removed tslint

* forgot to commit files

* made .eslintrc.js consistent for all subdirs and other cleanup

* [removed] includes and files keys from tsconfig.json

* removed file level linting exceptions and added details to line level

* added changeset

* fixed newly introduced linting errors from rebase

* enable json import for batch submitter

* removed ecdsa-coder

* maybe a tsconfig issue?

* Update deploy.ts

Co-authored-by: smartcontracts <kelvinfichter@gmail.com>
Co-authored-by: platocrat <37757724+platocrat@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 15, 2021
1 parent 1424370 commit c87e4c7
Show file tree
Hide file tree
Showing 66 changed files with 1,472 additions and 278 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-fans-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/contracts': patch
---

Migrated from tslint to eslint. The preference for lint exceptions is as follows: line level, block level, file level, package level.
186 changes: 186 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
module.exports = {
"env": {
"browser": true,
"es6": true
},
"extends": [
"prettier",
],
"ignorePatterns": ["dist/**/*.ts"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"eslint-plugin-import",
"eslint-plugin-unicorn",
"eslint-plugin-jsdoc",
"eslint-plugin-prefer-arrow",
"eslint-plugin-react",
"@typescript-eslint",
],
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/member-delimiter-style": [
"off",
{
"multiline": {
"delimiter": "none",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-shadow": [
"error",
{
"hoist": "all"
}
],
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/quotes": "off",
"@typescript-eslint/semi": [
"off",
null
],
"@typescript-eslint/triple-slash-reference": [
"error",
{
"path": "always",
"types": "prefer-import",
"lib": "always"
}
],
"@typescript-eslint/type-annotation-spacing": "off",
"@typescript-eslint/unified-signatures": "error",
"arrow-parens": [
"off",
"always"
],
"brace-style": [
"off",
"off"
],
"comma-dangle": "off",
"complexity": "off",
"constructor-super": "error",
"curly": "error",
"dot-notation": "off",
"eol-last": "off",
"eqeqeq": [
"error",
"smart"
],
"guard-for-in": "error",
"id-blacklist": "off",
"id-match": "off",
"import/no-extraneous-dependencies": [
"error"
],
"import/no-internal-modules": "off",
"import/order": "off",
"indent": "off",
"jsdoc/check-alignment": "error",
"jsdoc/check-indentation": "error",
"jsdoc/newline-after-description": "error",
"linebreak-style": "off",
"max-classes-per-file": "off",
"max-len": "off",
"new-parens": "off",
"newline-per-chained-call": "off",
"no-bitwise": "off",
"no-caller": "error",
"no-cond-assign": "error",
"no-console": "off",
"no-debugger": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "error",
"no-empty": "error",
"no-eval": "error",
"no-extra-bind": "error",
"no-extra-semi": "off",
"no-fallthrough": "off",
"no-invalid-this": "off",
"no-irregular-whitespace": "off",
"no-multiple-empty-lines": "off",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-redeclare": "error",
"no-return-await": "error",
"no-sequences": "error",
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "off",
"no-undef-init": "error",
"no-underscore-dangle": "off",
"no-unsafe-finally": "error",
"no-unused-expressions": "off",
"no-unused-labels": "error",
"no-use-before-define": "off",
"no-var": "error",
"object-shorthand": "error",
"one-var": [
"error",
"never"
],
"padded-blocks": [
"off",
{
"blocks": "never"
},
{
"allowSingleLineBlocks": true
}
],
"prefer-arrow/prefer-arrow-functions": "error",
"prefer-const": "error",
"prefer-object-spread": "error",
"quote-props": "off",
"quotes": "off",
"radix": "error",
"react/jsx-curly-spacing": "off",
"react/jsx-equals-spacing": "off",
"react/jsx-tag-spacing": [
"off",
{
"afterOpening": "allow",
"closingSlash": "allow"
}
],
"react/jsx-wrap-multilines": "off",
"semi": "off",
"space-before-blocks": "error",
"space-before-function-paren": "off",
"space-in-parens": [
"off",
"never"
],
"unicorn/prefer-ternary": "off",
"use-isnan": "error",
"valid-typeof": "off"
}
};
3 changes: 1 addition & 2 deletions examples/truffle/test/erc20.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ contract('ERC20', (accounts) => {
const balance02 = await token.balanceOf.call(accounts[ 0 ])
assert.strictEqual(balance02.toNumber(), 9980)
})

/* eslint-disable no-underscore-dangle */

it('events: should fire Transfer event properly', async () => {
const res = await token.transfer(accounts[ 1 ], '2666', { from: accounts[ 0 ], gasPrice: 0 })
const transferLog = res.logs.find(
Expand Down
3 changes: 3 additions & 0 deletions integration-tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
"extends": "../.eslintrc.js"
}
14 changes: 12 additions & 2 deletions integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"lint": "yarn lint:fix && yarn lint:check",
"lint:fix": "prettier --config ./.prettierrc.json --write 'test/**/*.ts'",
"lint:check": "tslint --format stylish --project .",
"lint:check": "eslint -c .eslintrc.js --ext .ts --format stylish .",
"build:integration": "./scripts/build.sh",
"build:contracts": "hardhat compile",
"build:contracts:ovm": "hardhat compile --network optimism",
Expand All @@ -23,15 +23,25 @@
"@ethersproject/providers": "^5.0.24",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@types/chai-as-promised": "^7.1.3",
"@types/chai": "^4.2.17",
"@types/chai-as-promised": "^7.1.3",
"@types/mocha": "^8.2.2",
"@types/rimraf": "^3.0.0",
"@types/shelljs": "^0.8.8",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"chai": "^4.3.3",
"chai-as-promised": "^7.1.1",
"docker-compose": "^0.23.8",
"envalid": "^7.1.0",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ban": "^1.5.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^35.1.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-unicorn": "^32.0.1",
"ethereum-waffle": "^3.3.0",
"ethers": "^5.0.32",
"hardhat": "^2.2.1",
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"compilerOptions": {
"resolveJsonModule": true
},
"include": ["./test", "sync-tests/*.ts"],
"include": ["./test", "sync-tests/*.ts", "./artifacts/**/*.json", "./artifacts-ovm/**/*.json"],
"files": ["./hardhat.config.ts"]
}
7 changes: 0 additions & 7 deletions integration-tests/tslint.json

This file was deleted.

3 changes: 3 additions & 0 deletions packages/batch-submitter/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
"extends": "../../.eslintrc.js"
}
16 changes: 11 additions & 5 deletions packages/batch-submitter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"clean": "rimraf cache/ dist/ ./tsconfig.build.tsbuildinfo",
"lint": "yarn lint:fix && yarn lint:check",
"lint:fix": "prettier --config .prettierrc.json --write \"hardhat.config.ts\" \"{src,exec,test}/**/*.ts\"",
"lint:check": "tslint --format stylish --project .",
"lint:check": "eslint -c .eslintrc.js --ext .ts --format stylish .",
"test": "hardhat test --show-stack-traces"
},
"keywords": [
Expand Down Expand Up @@ -57,7 +57,17 @@
"@types/rimraf": "^3.0.0",
"@types/sinon": "^9.0.10",
"@types/sinon-chai": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"chai": "^4.2.0",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ban": "^1.5.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^35.1.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-unicorn": "^32.0.1",
"ethereum-waffle": "3.0.0",
"ganache-core": "^2.13.2",
"hardhat": "^2.2.1",
Expand All @@ -66,10 +76,6 @@
"rimraf": "^2.6.3",
"sinon": "^9.2.4",
"sinon-chai": "^3.5.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-focused-test": "^0.5.0",
"tslint-plugin-prettier": "^2.3.0",
"typescript": "^4.2.3"
},
"resolutions": {
Expand Down
9 changes: 5 additions & 4 deletions packages/batch-submitter/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"resolveJsonModule": true
}
"extends": "../../tsconfig.json",
"compilerOptions": {
"resolveJsonModule": true
}
}

3 changes: 0 additions & 3 deletions packages/batch-submitter/tslint.json

This file was deleted.

3 changes: 3 additions & 0 deletions packages/common-ts/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
"extends": "../../.eslintrc.js"
}
16 changes: 11 additions & 5 deletions packages/common-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"clean": "rimraf dist/ ./tsconfig.build.tsbuildinfo",
"lint": "yarn lint:fix && yarn lint:check",
"lint:fix": "prettier --config .prettierrc.json --write '{src,test}/**/*.ts'",
"lint:check": "tslint --format stylish --project .",
"lint:check": "eslint -c .eslintrc.js --ext .ts --format stylish .",
"test": "ts-mocha test/*.spec.ts"
},
"devDependencies": {
Expand All @@ -24,15 +24,21 @@
"@types/pino": "^6.3.6",
"@types/pino-multi-stream": "^5.1.1",
"@types/prettier": "^2.2.3",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"chai": "^4.3.4",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ban": "^1.5.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsdoc": "^35.1.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-unicorn": "^32.0.1",
"mocha": "^8.4.0",
"prettier": "^2.2.1",
"supertest": "^6.1.3",
"ts-mocha": "^8.0.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-focused-test": "^0.5.0",
"tslint-plugin-prettier": "^2.3.0",
"typescript": "^4.2.3"
},
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/common-ts/src/base-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ export class BaseService<T> {
/**
* Combines user provided and default options.
*/
function mergeDefaultOptions<T>(
const mergeDefaultOptions = <T>(
options: T,
optionSettings: OptionSettings<T>
): T {
): T => {
for (const optionName of Object.keys(optionSettings)) {
const optionDefault = optionSettings[optionName].default
if (optionDefault === undefined) {
Expand All @@ -132,7 +132,7 @@ function mergeDefaultOptions<T>(
/**
* Performs option validation against the option settings
*/
function validateOptions<T>(options: T, optionSettings: OptionSettings<T>) {
const validateOptions = <T>(options: T, optionSettings: OptionSettings<T>) => {
for (const optionName of Object.keys(optionSettings)) {
const optionValidationFunction = optionSettings[optionName].validate
if (optionValidationFunction === undefined) {
Expand Down
3 changes: 0 additions & 3 deletions packages/common-ts/tslint.json

This file was deleted.

7 changes: 7 additions & 0 deletions packages/contracts/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
"extends": "../../.eslintrc.js",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
}
}
Loading

0 comments on commit c87e4c7

Please sign in to comment.