Skip to content

Implement new processor API #138

Closed
GoogleForCreators/web-stories-wp
#6765
@btmills

Description

@btmills
Member

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:

https://github.com/eslint/eslint-plugin-markdown/blob/66b565b3763c30dcbc193e4bb74aee976860335d/lib/processor.js#L12

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:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @btmills

    Issue actions

      Implement new processor API · Issue #138 · eslint/markdown