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

[Feature Request][Enhancement] json file output #2899

Closed
MIreland opened this issue Apr 5, 2024 · 5 comments · Fixed by #2925
Closed

[Feature Request][Enhancement] json file output #2899

MIreland opened this issue Apr 5, 2024 · 5 comments · Fixed by #2925
Labels
A-linter Area - Linter E-Help Wanted Experience level - For the experienced collaborators good first issue Experience Level - Good for newcomers

Comments

@MIreland
Copy link

MIreland commented Apr 5, 2024

Right now, there isn't a clean way to get JSON output into a file. In this sample project, I use:

"oxlint:json": "mkdir -p artifacts && oxlint src --format json > artifacts/oxc-lint.json",

But the output is invalid:

[
	{"message": "eslint-plugin-react(jsx-no-target-blank): Using target=`_blank` without rel=`noreferrer` (which implies rel=`noopener`) is a security risk in older browsers: see https://mathiasbynens.github.io/rel-noopener/#recommendations","severity": "warning","causes": [],"help": "add rel=`noreferrer` to the element","filename": "src/App.tsx","labels": [{"span": {"offset": 595,"length": 8}}],"related": []},
	{"message": "eslint-plugin-react(jsx-no-target-blank): Using target=`_blank` without rel=`noreferrer` (which implies rel=`noopener`) is a security risk in older browsers: see https://mathiasbynens.github.io/rel-noopener/#recommendations","severity": "warning","causes": [],"help": "add rel=`noreferrer` to the element","filename": "src/App.tsx","labels": [{"span": {"offset": 727,"length": 8}}],"related": []}
]

Finished in 10ms on 5 files with 89 rules using 10 threads.
Found 2 warnings and 0 errors.

On a similar note (I can make this a separate ticket if desired), we would REALLY appreciate being able to specify multiple reporters- specifically, we want human-readable terminal output at the same time we generate machine-readable JSON output.

We currently use this eslint wrapper to achieve this with eslint. It would be great to offer it natively for oxlint.

@Boshen Boshen added E-Help Wanted Experience level - For the experienced collaborators A-linter Area - Linter good first issue Experience Level - Good for newcomers labels Apr 6, 2024
@R11baka
Copy link

R11baka commented Apr 7, 2024

Not clear what is expected result? add an option to save to file ? or change formatting ?

@MIreland
Copy link
Author

MIreland commented Apr 7, 2024

Two requests wrapped in one here:

  • allow saving JSON to a file via a flag
  • allow using multiple reporters (save to file + still have terminal output)

Boshen pushed a commit that referenced this issue Apr 9, 2024
…2925)

this allows the ability to redirect the stdout to so can create a valid
json file

this also matches with eslint's format option

closes #2899
@Boshen
Copy link
Member

Boshen commented Apr 9, 2024

allow using multiple reporters (save to file + still have terminal output)

If eslint doesn't support this, I wonder if you can run oxlint twice with different formatters given oxlint is super fast 😅

@MIreland
Copy link
Author

MIreland commented Apr 9, 2024

@Boshen - that definitely would work, but feels a bit verbose to have every script look like:
"lint": "oxlint --import-plugin --jest-plugin --jsx-a11y-plugin --react-perf-plugin --config=../../oxlint.json && oxlint --import-plugin --jest-plugin --jsx-a11y-plugin --react-perf-plugin --config=../../oxlint.json --format=json"

If we don't want to allow multiple reporters, how would you feel about me opening a PR with a default-with-json format that requires a --output-filename parameter?

@Boshen
Copy link
Member

Boshen commented Apr 10, 2024

@MIreland Happy to accept any eslint cli options, https://eslint.org/docs/latest/use/command-line-interface#-o---output-file

On accepting multiple formatters, you may raise another issue for it, although eslint doesn't accept multiple formatters, I may be able to bend the rule because it's not that hard to implement 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter E-Help Wanted Experience level - For the experienced collaborators good first issue Experience Level - Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants