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

feat(packages): eslint-plugin-turbo #1620

Merged
merged 4 commits into from
Aug 4, 2022
Merged

feat(packages): eslint-plugin-turbo #1620

merged 4 commits into from
Aug 4, 2022

Conversation

tknickman
Copy link
Member

@tknickman tknickman commented Aug 2, 2022

eslint-plugin-turbo

Only one rule for now: error when an env var is provided that is not present in the turbo config.

NOTE: I'm building turbo-utils right now, because I want to tree shake it. But, I'm still exploring options for this with a pure internal library.

Fixes TURBO-201

@vercel
Copy link

vercel bot commented Aug 2, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
turbo-site ✅ Ready (Inspect) Visit Preview Aug 4, 2022 at 2:03PM (UTC)

Copy link
Contributor

@nathanhammond nathanhammond left a comment

Choose a reason for hiding this comment

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

First bit.

packages/eslint-plugin-turbo/README.md Outdated Show resolved Hide resolved
packages/eslint-plugin-turbo/README.md Outdated Show resolved Hide resolved
packages/eslint-plugin-turbo/README.md Outdated Show resolved Hide resolved
packages/eslint-plugin-turbo/README.md Show resolved Hide resolved
{
"pipeline": {
"build": {
"dependsOn": ["^build", "$MY_API_TOKEN"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we actually detect package vs. task vs. global?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did spend some time thinking about this, and I don't believe we could reliably infer this (without actually running the tasks)

Copy link
Contributor

Choose a reason for hiding this comment

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

I made the comment because the correct patterns were in different locations and a tiny bit confusing. I don't think there is anything wrong with it; but it did make me pause.

packages/eslint-plugin-turbo/README.md Outdated Show resolved Hide resolved
packages/eslint-plugin-turbo/lib/constants.ts Outdated Show resolved Hide resolved
packages/eslint-plugin-turbo/lib/types.ts Outdated Show resolved Hide resolved
packages/eslint-plugin-turbo/package.json Show resolved Hide resolved
packages/turbo-utils/package.json Show resolved Hide resolved
packages/eslint-plugin-turbo/package.json Outdated Show resolved Hide resolved
packages/turbo-ignore/package.json Outdated Show resolved Hide resolved
Copy link
Contributor

@mehulkar mehulkar left a comment

Choose a reason for hiding this comment

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

Small suggestion that may or may not conform to the existing workflow in the repo: It would be helpful to split the work that creates the utils package into a separate commit.

Other than that a meager review and mostly a bunch of questions! The meat of the implementation and tests look good to me other than @nathanhammond's suggestions!

packages/eslint-plugin-turbo/README.md Show resolved Hide resolved
packages/eslint-plugin-turbo/jest.config.js Show resolved Hide resolved
packages/eslint-plugin-turbo/lib/constants.ts Outdated Show resolved Hide resolved
function findDependsOnEnvVars({
dependencies,
}: {
dependencies?: Array<string>;
Copy link
Contributor

Choose a reason for hiding this comment

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

TS q... iiuc ? means that the argument is optional. Could we get by with assigning a default value to the arg (and therefore prevent the if check in the function body? (not a blocker, just curious!

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a transitive-to-user-input ?, so at some point it'll have to be optional. We can choose where we put the if statement, basically.

packages/eslint-plugin-turbo/tsconfig.json Show resolved Hide resolved
@tknickman
Copy link
Member Author

tknickman commented Aug 3, 2022

Addressed everything but the naming for now (still thinking about this one). Thanks for the reviews!

@tknickman
Copy link
Member Author

Name updated (no-undeclared-env-vars) ready for re-review

@nathanhammond nathanhammond added the pr: fixship A PR which is approved with notes and does not require re-review. label Aug 4, 2022
Copy link
Contributor

@nathanhammond nathanhammond left a comment

Choose a reason for hiding this comment

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

Tiny things!

```json
{
"rules": {
"turbo/rule-name": "error"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"turbo/rule-name": "error"
"turbo/no-undeclared-env-vars": "error"

{
"name": "eslint-plugin-turbo",
"version": "0.0.1",
"description": "Static analysis for turbo",
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you hold your pinky out when you drink your coffee?

Suggested change
"description": "Static analysis for turbo",
"description": "ESLint plugin for Turborepo",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: fixship A PR which is approved with notes and does not require re-review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants