question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow processor API to be configurable and to formally be able to lint both a file and its blocks

See original GitHub issue

Update: see updated description below

The version of ESLint you are using.

7.29.0

The problem you want to solve.

A few facts:

  1. Per the v7.29.0 blog release, further changes are anticpated toward dropping CLIEngine.

  2. Its replacement, the ESLint class, relies on some async-only methods.

  3. However, ESLint rules do not, and per @nzakas in this comment, there have been no discussions or apparent interest in making Linter async so that asynchronous rules could be supported.

This all means that if CLIEngine is dropped, rules cannot take advantage of ESLint linting within their own rules.

Why would one want to run linting within a linting rule?

In eslint-plugin-jsdoc, we allow it in three cases all within our jsdoc/check-examples rule:

  1. To lint JavaScript code within @example tags

  2. To lint a JavaScript value within @default/@defaultvalue tags

  3. To lint a JavaScript expression within the likes of @param {type} [name=default] or @property {type} [name=default]

Your take on the correct solution to problem.

Besides adding synchronous methods, I would think that allowing some config to be passed to the ESLint class which triggered use of the synchronous rather than asynchronous methods would be sufficient.

Are you willing to submit a pull request to implement this change?

Yes (if my health-based limits on energy and concentration allow).

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:13
  • Comments:25 (24 by maintainers)

github_iconTop GitHub Comments

4reactions
btmillscommented, Feb 21, 2022

I looked at standardizing the existing workaround in which preprocess() returns the full file text as the first “block” in the array. However, that mean would mean the processor and not the user determines when to further lint the file. In contrast, the processor API change released in ESLint v6 was all about giving users control over processors.

I’m now thinking the processor key should optionally accept an array of multiple processors to apply, and the special value "passthrough" would tell ESLint to lint the file as normal in addition to running any other processors:

const config = {
    files: ["*.js"],
    processor: [
        // Continue to lint this file as normal...
        "passthrough",
        // ...but also extract and lint any JSDoc blocks.
        "jsdoc/processor"
    ]
};
3reactions
btmillscommented, Oct 20, 2021

Yes, assuming there are no objections, I need to write an RFC that will allow linting a file and extracting its blocks with a processor and linting those too.

There’s already an unofficial way to do that mentioned in #14198, so the RFC may just pave that cow path and add make it configurable.

The second half of this is asking for processor configuration, but if the RFC unblocks the first half, I believe the second half can be achieved with parser options for the processor’s parser and may not need any further changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kafka Streams Processor API | Confluent Documentation
The Processor API allows developers to define and connect custom processors and to interact with state stores. With the Processor API, you can...
Read more >
Android Lint API Guide - Google Samples
A configuration provides extra information or parameters to lint on a per project, or even per directory basis. For example, the lint.xml files...
Read more >
Plugins & Parsers - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Configuration — SQLFluff 1.4.5 documentation
SQLFluff accepts configuration either through the command line or through configuration files. There is rough parity between the two approaches with the ......
Read more >
Validate GitLab CI/CD configuration
Use the CI Lint tool to check the validity of GitLab CI/CD configuration. You can validate the syntax from a .gitlab-ci.yml file or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found