mdx-js / eslint-mdx

ESLint Parser/Plugin for MDX
https://npmjs.org/eslint-plugin-mdx
MIT License
264 stars 32 forks source link

feat: allow to ignore remark config #374

Closed lucasvazq closed 2 years ago

lucasvazq commented 2 years ago

This is just a proposal, and any kind of feedback is welcome.

I add a new parserOption named ignoreRemarkConfig. It can take two values: true or false. If it isn't defined, the value is treated as false. What this does? It allow to ignore the remark config that is auto loaded.

Why this can be useful? I just try to improve the workaround commented in the following issue: https://github.com/mdx-js/eslint-mdx/issues/338#issuecomment-1059858710 If I have a remark config in my package.json that uses ESM plugins, I can't execute eslint because it throws an error. So, an alternative is to set the remark config in another place where it can't be autoloaded, then run remark, and, afterall, run eslint.

This is what I typically do:

# I set my remark config in `my_custom_remark_config.yml`.

# First of all, I run remark using my custom config file, that have ESM plugins:
yarn run remark **/*.mdx --no-stdout -r my_custom_remark_config.yml

# Then, I run eslint:
yarn run eslint . --fix --ext .mdx

I think this is very weird, so I purpose a way to keep the remark config where It should go. The biggest benefit is that I can save my configuration to package.json and avoid to have any more files in my project :smile:

If I set ignoreRemarkConfig to true, I just need to run:

yarn run remark **/*.mdx --no-stdout
yarn run eslint . --fix --ext .mdx
codesandbox-ci[bot] commented 2 years ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

codecov-commenter commented 2 years ago

Codecov Report

Merging #374 (b1db764) into master (51a3ee0) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #374   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines          515       519    +4     
  Branches       109       111    +2     
=========================================
+ Hits           515       519    +4     
Impacted Files Coverage Δ
packages/eslint-mdx/src/parser.ts 100.00% <ø> (ø)
packages/eslint-mdx/src/processor.ts 100.00% <100.00%> (ø)
packages/eslint-plugin-mdx/src/rules/remark.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 51a3ee0...b1db764. Read the comment docs.

JounQin commented 2 years ago

@wooorm Ready to release.

wooorm commented 2 years ago

Done, thanks for your patience! https://github.com/mdx-js/eslint-mdx/releases/tag/v1.17.0