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

fix(plugin-eslint): eslint startline can be zero #563

Merged
merged 5 commits into from
Mar 18, 2024

Conversation

markusnissl
Copy link
Contributor

@markusnissl markusnissl commented Mar 13, 2024

In case tsconfig does not contain correct setup, e.g., "strictNullChecks": true, eslint throws warnings for line "zero". The current schema does not show the warning, it just throws an internal error. This fix allows for warning on line zero to be collected for the report.

Fixes issues such as:

{
  "code": "too_small",
  "minimum": 0,
  "type": "number",
  "inclusive": false,
  "exact": false,
  "message": "Number must be greater than 0",
  "path": [
    117,
    "details",
    "issues",
    3,
    "source",
    "position",
    "startLine"
  ]
},

for issues like
0:1 warning This rule requires the strictNullChecks compiler option to be turned on to function correctly @typescript-eslint/prefer-nullish-coalescing

Copy link

nx-cloud bot commented Mar 13, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 2db0d1d. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


🟥 Failed Commands
nx run-collect
✅ Successfully ran 7 targets

Sent with 💌 from NxCloud.

Copy link
Collaborator

@matejchalk matejchalk left a comment

Choose a reason for hiding this comment

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

We don't want to consume source file links for line 0, they don't represent an actual file location so we can't create file snippets from them in the portal.

Instead, I suggest we either:

  • omit the position altogether if line is 0 - similar to how we handle column 0 in fix(plugin-eslint): handle rules which emit column 0 #522
  • since it's more of a configuration error than an actual problem in the source code, don't create an issue at all, instead just print a warning or throw an error

@markusnissl
Copy link
Contributor Author

@matejchalk I changed PR to implement first solution.

While I like the second solution to throw an error, it is against the idea of "monitoring" the progress for transformation as one has e.g., to fix some projects in monorepos to have the rules in place.

packages/models/src/lib/issue.ts Outdated Show resolved Hide resolved
packages/plugin-eslint/src/lib/runner/transform.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@matejchalk matejchalk left a comment

Choose a reason for hiding this comment

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

Thanks for the fix 🙂

@matejchalk matejchalk changed the title fix: eslint startline can be zero fix(plugin-eslint): eslint startline can be zero Mar 18, 2024
@matejchalk matejchalk merged commit 4eefb35 into code-pushup:main Mar 18, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants