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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(build): add eslint scripts and default configs #2572

Merged
merged 2 commits into from May 28, 2019
Merged

Conversation

raymondfeng
Copy link
Contributor

@raymondfeng raymondfeng commented Mar 11, 2019

Phase 1 for #2492:

  • Add @loopback/eslint-config
  • Add lb-eslint to @loopback/build

Checklist

馃憠 Read and sign the CLA (Contributor License Agreement) 馃憟

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

@bajtos
Copy link
Member

bajtos commented Mar 12, 2019

Yay for starting with a smaller patch first 馃憤 鉂わ笍

'@typescript-eslint/prefer-interface': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/ban-types': 'error',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in #2492, our code base is violating ban-types rule in many places. Let's disable this rule in this initial pull request to make the migration from tslint to eslint easier & faster.

packages/eslint-config/.npmrc Outdated Show resolved Hide resolved
packages/eslint-config/README.md Outdated Show resolved Hide resolved
packages/eslint-config/package.json Show resolved Hide resolved
packages/eslint-config/package.json Outdated Show resolved Hide resolved
packages/eslint-config/.eslintrc.js Outdated Show resolved Hide resolved
@bajtos bajtos added feature Internal Tooling Issues related to our tooling and monorepo infrastructore labels Mar 12, 2019
.eslintignore Outdated Show resolved Hide resolved
.travis.yml Outdated Show resolved Hide resolved
Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is still not addressed: #2572 (comment)

Would it help you @raymondfeng if I took a look at the differences between tslint and your proposed config myself?

"eslint": "^5.14.1",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-eslint-plugin": "^2.0.1",
"eslint-plugin-mocha": "^5.3.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these new dependencies at root level should not be needed as long as we always use the eslint config bundled as part of @loopback/build. Could you please try to remove them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these new dependencies at root level should not be needed as long as we always use the eslint config bundled as part of @loopback/build. Could you please try to remove them?

鈽濓笍

@raymondfeng
Copy link
Contributor Author

@bajtos I'm busy with other PRs and will visit this one again soon.

@raymondfeng
Copy link
Contributor Author

@bajtos I have updated ESLint configuration to reflect existing tslint rules.

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good, please address my minor comments below before landing.

I didn't test this new PR in practice, I am considering this PR as an initial version that will be incrementally improved in follow-up pull requests as needed.

"eslint": "^5.14.1",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-eslint-plugin": "^2.0.1",
"eslint-plugin-mocha": "^5.3.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these new dependencies at root level should not be needed as long as we always use the eslint config bundled as part of @loopback/build. Could you please try to remove them?

鈽濓笍

sourceType: 'module',
project: './tsconfig.json',
ecmaFeatures: {
ecmaVersion: 2017,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'@typescript-eslint/adjacent-overload-signatures': 'error', // tslint:adjacent-overload-signatures
'@typescript-eslint/prefer-for-of': 'error', // tslint:prefer-for-of
'@typescript-eslint/unified-signatures': 'error', // tslint:unified-signatures
'@typescript-eslint/no-explicit-any': 'error', // tslint:no-explicit-any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, we are using no-any rule, can you enable it too please? Or is @typescript-eslint/no-explicit-any replacement for tslint:no-any and it's just the comment that's wrong here?

See https://github.com/strongloop/loopback-next/blob/4b68ef850318e865074449f2892e4f616aebaa0c/packages/tslint-config/tslint.common.json#L12

'@typescript-eslint/await-thenable': 'error', // tslint:await-promise: [true, 'PromiseLike', 'RequestPromise'],

// https://github.com/xjamundx/eslint-plugin-promise
// tslint:no-floating-promises: [true, 'PromiseLike', 'RequestPromise'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, no-floating-promise is actually very useful! It detects situations where people forget to await a promise.

Here is the tracking issue: typescript-eslint/typescript-eslint#464 and pull request in progress: typescript-eslint/typescript-eslint#495

Please rework the comment to point to those two links instead of https://github.com/xjamundx/eslint-plugin-promise.

I am ok to move forward with this PR even if no-floating-promises is not supported yet.

};

/**
* tslint rules from `@loopback/tslint-config` for comparison
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Internal Tooling Issues related to our tooling and monorepo infrastructore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants