Skip to content

Configure file name based on block meta #226

Closed
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Some projects use ESLint overrides to run different lint rules on files based on their file name. It'd be nice if the meta for a code block was respected in some way to retrieve file name, so that overrides can be used for code blocks too.

Right now, eslint-plugin-markdown always uses a name in this format:
https://github.com/eslint/eslint-plugin-markdown/blob/4d9f36f5c5fd1b5d3b1957913118cd76a92750f2/lib/processor.js#L299

Proposal: use a file name described by the code block's meta instead of index when possible?

Pending investigation: I don't know that there's a standard way to describe that file name. https://astexplorer.net/#/gist/0cce3ae28ac100aa5d78e3a88fdbf15e/e79a0e179def1bad1d8d7771f789709177c28a9a shows that the following codeblock's meta is the raw string "example abc=def" in remark:

```javascript example abc=def
console.log('!');
```

Context/example: in https://github.com/JoshuaKGoldberg/create-typescript-app, *.json files except package.json files have jsonc/sort-keys run: https://github.com/JoshuaKGoldberg/create-typescript-app/blob/76a75186fd89fc3f66e4c1254c717c28d70afe0d/.eslintrc.cjs#L94. In https://github.com/JoshuaKGoldberg/create-typescript-app/pull/986/files#diff-cc908ca4b57d59e44123c8b13deee7af64523aa40e21f69f11d4c604af276ff6R19 a codeblock intended to be a package.json is create-typescript-app/docs/FAQs.md/0_0.jsonc even with the meta. I had to manually disable the lint rule. I'd have preferred to instead extend the ESLint config's override to something like **/package.json.

I think this is a separate ask from #208. Not sure.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions