Skip to content

Commit

Permalink
replace tslint with eslint for typescript (#10900)
Browse files Browse the repository at this point in the history
* replace tslint with eslint for typescript

* remove many unneeded awaits and asyncs
* change console logs to console info
* ignore some more offensive files
* fix some interprolated values which could have been [object object]
* add missing dependencies
* try to have minimal changes

* use tsconfig/recommended instead of our tsconfig library as base.
Fix env tests use of typescript 4.0
for protocol package cannot extend because of bug in ts-node so instead just copy the config.
remove tslint.json files

* fix lint again

* dont add strict mode, its too brutal,

* add package validation

* help out future devs with instructions on how to fix error

* it works on my machine ok

* trust but verify. but dont actually trust

* use latest ts-node AND always run yarn ts-node to ensure the project one is used.

* removing patch-package since the only remaining place it was used was had been for tslint

* most of us dont need to decrypt to dont try automatically

* i think running in yarn added extra output that broke gh action so try this otherwise revert

* structs fro sol contracts are returned as objects with named keys (as well as number keys) but NOT as arrays.
  • Loading branch information
aaronmgdr authored and lvpeschke committed Feb 26, 2024
1 parent 5183647 commit e2afd56
Show file tree
Hide file tree
Showing 139 changed files with 917 additions and 1,147 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

280 changes: 280 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
/*
👋 Hi! This file was autogenerated by tslint-to-eslint-config.
https://github.com/typescript-eslint/tslint-to-eslint-config
It represents the closest reasonable ESLint configuration to this
project's original TSLint configuration.
We recommend eventually switching this configuration to extend from
the recommended rulesets in typescript-eslint.
https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md
Happy linting! 💖
*/
module.exports = {
env: {
es6: true,
node: true,
},
ignorePatterns: [
'**/node_modules/**',
'**/coverage/**',
'**/build/**',
'**/dist/**',
'**/lib/**',
'**/*.js',
'packages/protocol/build/**',
'packages/protocol/types/**',
'/packages/protocol/migrations_ts/**',
'packages/protocol/scripts/truffle/**',
// ignoring any files that for which "TSConfig does not include this file" error was given
'packages/protocol/scripts/utils.test.ts',
'packages/protocol/test',
'packages/protocol/truffle-config.js',
'packages/protocol/truffle-config0.8.js',
'packages/protocol/truffle-config-parent.js',
'packages/protocol/abis',
'packages/protocol/wagmi.config.ts',
'**/jest.config.js',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-type-checked',
],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: `${__dirname}`,
project: ['./packages/*/tsconfig.json'],
sourceType: 'module',
},
plugins: ['eslint-plugin-import', '@typescript-eslint'],
root: true,
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
// i dont trust this rule
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/array-type': [
'error',
{
default: 'array',
},
],
'@typescript-eslint/ban-types': [
'error',
{
types: {
Object: {
message: 'Avoid using the `Object` type. Did you mean `object`?',
},
Function: {
message:
'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.',
},
Boolean: {
message: 'Avoid using the `Boolean` type. Did you mean `boolean`?',
},
Number: {
message: 'Avoid using the `Number` type. Did you mean `number`?',
},
String: {
message: 'Avoid using the `String` type. Did you mean `string`?',
},
Symbol: {
message: 'Avoid using the `Symbol` type. Did you mean `symbol`?',
},
},
},
],
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': [
'off',
{
accessibility: 'explicit',
},
],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/member-delimiter-style': [
'off',
{
multiline: {
delimiter: 'none',
requireLast: true,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
},
],
'@typescript-eslint/naming-convention': [
'off',
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE'],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid',
},
],
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-floating-promises': 'error',
'@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': 'error',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@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/typedef': 'off',
'@typescript-eslint/unified-signatures': 'error',
'arrow-parens': ['off', 'always'],
'brace-style': ['off', 'off'],
'comma-dangle': 'off',
complexity: 'off',
'constructor-super': 'error',
'dot-notation': 'off',
'eol-last': 'off',
eqeqeq: ['error', 'smart'],
'guard-for-in': 'error',
'id-denylist': 'error',
'id-match': 'error',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: false,
},
],
'import/no-internal-modules': 'off',
indent: 'off',
'linebreak-style': 'off',
'max-classes-per-file': ['error', 1],
'max-len': 'off',
'new-parens': 'off',
'newline-per-chained-call': 'off',
'no-bitwise': 'error',
'no-caller': 'error',
'no-cond-assign': 'error',
'no-console': [
'error',
{
allow: [
'warn',
'dir',
'time',
'timeEnd',
'timeLog',
'trace',
'assert',
'clear',
'count',
'countReset',
'group',
'groupEnd',
'table',
'debug',
'info',
'dirxml',
'error',
'groupCollapsed',
'Console',
'profile',
'profileEnd',
'timeStamp',
'context',
],
},
],
'no-constant-condition': 'error',
'no-debugger': 'error',
'no-duplicate-case': 'error',
'no-duplicate-imports': 'error',
'no-empty': 'error',
'no-empty-function': 'off',
'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-restricted-syntax': ['error', 'ForInStatement'],
'no-return-await': 'error',
'no-sequences': 'error',
'no-shadow': 'off',
'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': 'error',
'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': ['off', 'never'],
'padded-blocks': [
'off',
{
blocks: 'never',
},
{
allowSingleLineBlocks: true,
},
],
'prefer-const': 'error',
'prefer-object-spread': 'error',
'quote-props': 'off',
quotes: 'off',
radix: 'error',
semi: 'off',
'space-before-function-paren': 'off',
'space-in-parens': ['off', 'never'],
'spaced-comment': [
'error',
'always',
{
markers: ['/'],
},
],
'use-isnan': 'error',
'valid-typeof': 'off',
},
}
6 changes: 5 additions & 1 deletion .github/workflows/publish-contracts-abi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ jobs:
env:
RELEASE_TYPE: ${{ env.RELEASE_TYPE }}
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}

# a safety check especially useful if some package is upgraded
- name: 'Validate ABIS Exports'
shell: bash
run: yarn validate_abis_exports
working-directory: packages/protocol
- name: Publish @celo/contracts
run: |
cat package.json
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"javascript.format.enable": false,
"editor.tabSize": 2,
"editor.detectIndentation": false,
"tslint.jsEnable": true,
"typescript.tsdk": "node_modules/typescript/lib",
"[javascriptreact][typescript][typescriptreact]": {
"editor.codeActionsOnSave": {
Expand Down
4 changes: 0 additions & 4 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,5 @@ yarn build --ignore docs
> github.com host key. Clone a repo or add the github host key to
> `~/.ssh/known_hosts` and then try again.
> When removing a dependency via `yarn remove some-package`, be sure to also run `yarn postinstall` so
> you aren't left with freshly unpackaged modules. This is because we use `patch-package`
> and the `postinstall` step which uses it is not automatically run after using `yarn remove`.
> The docs package relies on gitbook which has problems off of a fresh install. Running
> `yarn build --ignore docs` is a known workaround.
8 changes: 8 additions & 0 deletions packages/celotool/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
rules: {
'no-underscore-dangle': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'no-bitwise': 'off',
},
}
10 changes: 7 additions & 3 deletions packages/celotool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
"compare-versions": "^3.5.1",
"dotenv": "^16.0.3",
"ecurve": "^1.0.6",
"eth-lib": "^0.2.8",
"ethereum-cryptography": "1.2.0",
"generate-password": "^1.5.1",
"rlp": "^2.2.4",
"minimist": "^1.2.5",
"js-yaml": "^3.13.1",
"lodash": "^4.17.21",
"node-fetch": "^2.6.7",
Expand All @@ -39,11 +42,14 @@
"sleep-promise": "^8.0.1",
"string-hash": "^1.1.3",
"tiny-secp256k1": "2.2.1",
"chai": "^4.3.7",
"mocha": "^10.2.0",
"web3": "1.10.0",
"web3-eth-admin": "1.0.0-beta.55",
"yargs": "17.7.2"
},
"devDependencies": {
"@tsconfig/recommended": "^1.0.3",
"@celo/dev-utils": "0.0.1",
"@celo/protocol": "1.0.2",
"@types/bunyan": "1.8.8",
Expand All @@ -54,13 +60,11 @@
"@types/prompts": "^1.1.1",
"@types/string-hash": "^1.1.1",
"@types/yargs": "^13.0.2",
"chai": "^4.3.7",
"mocha": "^10.2.0",
"web3-core": "1.10.0"
},
"scripts": {
"cli": "TS_NODE_FILES=true ts-node -r tsconfig-paths/register src/cli.ts",
"lint": "tslint -c tslint.json --project tsconfig.json",
"lint": "yarn run --top-level eslint .",
"build": "tsc -b ."
},
"private": true
Expand Down
2 changes: 1 addition & 1 deletion packages/celotool/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env yarn run ts-node -r tsconfig-paths/register --cwd ../celotool
import yargs from 'yargs'

// tslint:disable-next-line: no-unused-expression
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
yargs
.scriptName('celotooljs')
.option('verbose', {
Expand Down
Loading

0 comments on commit e2afd56

Please sign in to comment.