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

Implement new processor API #138

Closed
btmills opened this issue Feb 26, 2020 · 0 comments · Fixed by #144 or GoogleForCreators/web-stories-wp#6765
Closed

Implement new processor API #138

btmills opened this issue Feb 26, 2020 · 0 comments · Fixed by #144 or GoogleForCreators/web-stories-wp#6765

Comments

@btmills
Copy link
Member

btmills commented Feb 26, 2020

The new processor API, as described in RFC #3, implemented in eslint/eslint#11552, and documented at https://eslint.org/docs/user-guide/configuring#specifying-processor, will allow users to chain processors to, for example, lint Vue and TypeScript code extracted from Markdown code blocks in addition to plain JS code that this plugin extracts today.

Currently, the processor has a hard-coded list of supported code block syntaxes:

const SUPPORTED_SYNTAXES = ["js", "javascript", "node", "jsx"];

If a code block has one of those info strings, the processor will extract the code and pass it to ESLint for linting. All other code blocks are ignored, making this plugin the gatekeeper for any additional languages.

With the new processor API, the processor will extract code from all code blocks that have a syntax set, and users will be able to configure ESLint to lint blocks of their choosing. For example, the following Markdown document would pass three code blocks to ESLint:

This code block will be extracted as `example.md/0.js`:

```js
const greeting = "Hello";
console.log(`${greeting}, world!`);
```

This code block will be extracted as `example.md/1.ts`:

```ts
const greeting: string = "Hello";
console.log(`${greeting}, world!`);
```

This code block will be extracted as `example.md/2.vue`:

```vue
<template>
    <p>{{ greeting }}, world!</p>
</template>

<script>
module.exports = {
    data() {
        return {
            greeting: "Hello"
        };
    }
};
</script>
```

Users will be able to configure linting of *.js, *.ts, and *.vue files individually as described in the processor configuration documentation.

ESLint v6 is the first version to contain the new processor API, so this will be a breaking change that increases the minimum supported ESLint version to v6.

This tracking issue incorporates the following feature requests:

@btmills btmills self-assigned this Feb 26, 2020
btmills added a commit that referenced this issue Feb 26, 2020
The new processor API first shipped in ESLint v6, which requires at
least Node.js v8.10.0.

Since Node.js v8 left LTS maintenance two months ago, I considered
dropping support for it as well and aligning with the supported engines
in ESLint v7, but I don't see a compelling reason not to support ESLint
v6.
btmills added a commit that referenced this issue Feb 26, 2020
The new processor API first shipped in ESLint v6, which requires at
least Node.js v8.10.0.

Since Node.js v8 left LTS maintenance two months ago, I considered
dropping support for it as well and aligning with the supported engines
in ESLint v7, but I don't see a compelling reason not to support ESLint
v6.
btmills added a commit that referenced this issue Feb 28, 2020
The new processor API first shipped in ESLint v6, which requires at
least Node.js v8.10.0.

Since Node.js v8 left LTS maintenance two months ago, I considered
dropping support for it as well and aligning with the supported engines
in ESLint v7, but I don't see a compelling reason not to support ESLint
v6.
@btmills btmills linked a pull request Mar 2, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment