Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: add support for css,json,markdown parsers #55

Merged
merged 3 commits into from
Feb 16, 2025
Merged

Conversation

ic4l4s9c
Copy link
Contributor

@ic4l4s9c ic4l4s9c commented Feb 13, 2025

ESLint officially supports linting of JSON, Markdown and CSS files.
This PR brings compatibility with currently existing parsers/plugins for these languages.

@dukeluo
Copy link
Owner

dukeluo commented Feb 14, 2025

Hi @ic4l4s9c, thank you for your PR! I appreciate the time and effort you’ve put into contributing to this plugin.

could you please provide more context about the changes? For example, what specific improvements or benefits does this PR introduce? are there any examples about this?

Copy link

codecov bot commented Feb 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (eb30d9e) to head (b399c0b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #55   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           14        14           
  Lines         1048      1073   +25     
=========================================
+ Hits          1048      1073   +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ic4l4s9c
Copy link
Contributor Author

ic4l4s9c commented Feb 14, 2025

@dukeluo, thank you for quick response and a great plugin, here is the breakdown of my changes:

This PR focuses of two issues:

  1. Currently the preprocessor provided by this plugin breaks linting of every non-source code file that is matched by it.

Here is the demo repo:

If you run eslint ./ there you will see multiple errors like this:

  0:0  error  Parsing error: Cannot read properties of undefined

This happens since preprocess function of this plugin doesn't return text of matched files.
Also, not having supportsAutofix set to true in preprocessor breaks eslint ./ --fix for all linted files.

If you comment out configuration of eslint-plugin-check-file in eslint.config.js you will see auto-fix working and parsing errors disappear.

  1. Currently this plugin lacks the ability to enforce naming conventions for file types that do not produce Program as their root node in AST.

(You can also see this behavior of not being able to report filename-naming-convention errors for *.md and *.css files in the demo repo.)

There is not much documentation on this, but you can see here that depending on the parsed language eslint returns different types of root nodes in AST:

  • Document for JSON
  • root for Markdown
  • StyleSheet for CSS

This PR enables every rule to execute on other types of root AST nodes.

@dukeluo
Copy link
Owner

dukeluo commented Feb 15, 2025

@ic4l4s9c i see, thanks for your context, now i know the issue here.

@ic4l4s9c ic4l4s9c changed the title feat: add support for non-js/ts parsers feat: add support for css,json,markdown parsers Feb 15, 2025
@dukeluo dukeluo merged commit 9e35a04 into dukeluo:main Feb 16, 2025
5 checks passed
@dukeluo
Copy link
Owner

dukeluo commented Feb 16, 2025

@ic4l4s9c thanks for your contribution! it has been released in version 3.1.0!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants