Git Product home page Git Product logo

Comments (20)

cyberixae avatar cyberixae commented on May 22, 2024 4

I made a pull request for adding it to a project. I get the following error message.

/home/travis/build/maasglobal/scrapql/README.md
  0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: README.md/0_0.ts.
The file must be included in at least one of the projects provided
  0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: README.md/1_1.ts.
The file must be included in at least one of the projects provided
...

See https://github.com/maasglobal/scrapql/pull/73/files
and https://travis-ci.com/github/maasglobal/scrapql/builds/160517417

from eslint-plugin-markdown.

DetachHead avatar DetachHead commented on May 22, 2024 4

Having the same issue as @mohanraj-r, can this issue be reopened as it doesn't seem possible to use parserOptions.project with this plugin

from eslint-plugin-markdown.

mohanraj-r avatar mohanraj-r commented on May 22, 2024 3

@btmills Thanks for this plugin!
@cyberixae

I faced the same error for my typescript project when I used js or javascript for the code blocks. But the errors went away once I switched to ts or typescript (which seems different than your situation).

Error:

  0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: README.md/0_0.js.
The file must be included in at least one of the projects provided

Setup that is working for me currently with v2:

.eslintrc.js

module.exports = {
    root: true,
    parser: '@typescript-eslint/parser',
    parserOptions: {
        project: './tsconfig.eslint.json',
    },
  plugins: [
        'markdown',
    ],
overrides: [
        {
            // Enable the Markdown processor for all .md files.
            files: ['**/*.md'],
            processor: 'markdown/markdown',
        },
    ]
}

tsconfig.eslint.json:

{
    "compilerOptions": { "strict": true },
    "include": ["./packages/**/*.ts", "*.js"]
}

I tried including "**/*.md/*.js" in the include list above - but it didn't seem to make a difference.

from eslint-plugin-markdown.

alex996 avatar alex996 commented on May 22, 2024 2

Now that [email protected] is out, any chance this could be readdressed?

from eslint-plugin-markdown.

hugotox avatar hugotox commented on May 22, 2024 2

Same issue. Any known workaround?

from eslint-plugin-markdown.

viT-1 avatar viT-1 commented on May 22, 2024 2

@btmills Why #114 was closed? Where I can see working configuration example for Typescript? I tried your example, but no success

from eslint-plugin-markdown.

btmills avatar btmills commented on May 22, 2024 1

Unfortunately it's not possible to use type-aware linting rules with any ESLint processors, this Markdown plugin included. Since code blocks aren't real .ts files on disk, the TypeScript compiler doesn't know how readme.md/0_0.ts fits into any known tsconfig.json. If you remove parserOptions.project, you should still be able to use the @typescript-eslint rules that don't require a tsconfig.json. For more details, check out #155 (comment) from the PR where I added the TypeScript example to the repository.

from eslint-plugin-markdown.

btmills avatar btmills commented on May 22, 2024 1

@laozhu remove parserOptions.project from your config for Markdown code blocks. tsc doesn't support type-aware lint rules in Markdown code blocks. For details, see #114 (comment).

from eslint-plugin-markdown.

mysticatea avatar mysticatea commented on May 22, 2024

Thank you for this issue.

For now, we cannot check ts code blocks. But ESLint 6 will support multiple processors (eslint/eslint#11552), then we will get the ability to lint ts code blocks.

from eslint-plugin-markdown.

btmills avatar btmills commented on May 22, 2024

👋 I'm now actively working on implementing the new processor API so that this plugin can extract TypeScript code blocks and pass them to ESLint! I'm tracking progress in #138, so subscribe to that issue if you'd like updates, and I'll close this so that #138 is the primary issue for this work.

from eslint-plugin-markdown.

cyberixae avatar cyberixae commented on May 22, 2024

I see #138 is now closed. Does this mean that TypeScript is now supported? There is no mention of TypeScript in readme.

from eslint-plugin-markdown.

btmills avatar btmills commented on May 22, 2024

v2.0.0-alpha.0, released this weekend, should work with ```ts code blocks! Please try it out and let me know how it goes. I'm also working on a set of examples, so if you're so inclined, I'd welcome a PR to add add an examples/typescript subdirectory with TypeScript working!

from eslint-plugin-markdown.

cyberixae avatar cyberixae commented on May 22, 2024

Maybe adding sourceType: 'module' to parserOptions breaks markdown plugin.

from eslint-plugin-markdown.

viT-1 avatar viT-1 commented on May 22, 2024

Same issue, if add *.md mask for linting.
Steps for reproduce:

  1. change eslint **/*.{ts,json,js} to eslint **/*.{ts,json,js,md} in package.json
  2. npm run lint
  3. Have error:
0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: readme.md\0_0.js.
The file must be included in at least one of the projects provided

from eslint-plugin-markdown.

btmills avatar btmills commented on May 22, 2024

@viT-1 if something is broken in the TypeScript example, please open an issue describing what's broken or better yet a PR to fix it! If you're able to use some @typescript-eslint rules but not the type-aware rules, see the comment above you for why that's not currently possible.

from eslint-plugin-markdown.

laozhu avatar laozhu commented on May 22, 2024

The same problem here, any workaround to avoid the error message from tsc?

Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: no-console.md/2_2.ts.
The file must be included in at least one of the projects provided.

from eslint-plugin-markdown.

laozhu avatar laozhu commented on May 22, 2024

Thank you, solved this. Some types-required rules have to be disabled for typescript blocks in markdown.

from eslint-plugin-markdown.

iambumblehead avatar iambumblehead commented on May 22, 2024

I've tried changing the eslint command for a project here from "eslint --ext .ts,.tsx,.js ." to "eslint ." and am seeing the same error reported by others here

/home/bumble/software/snabbdom/README.md
  790:1  error  Parsing error: ESLint was configured to run on `<tsconfigRootDir>/README.md/33_33.tsx` using `parserOptions.project`: 
- <tsconfigRootDir>/tsconfig.json
- <tsconfigRootDir>/test/tsconfig.json
However, none of those TSConfigs include this file. Either:
- Change ESLint's list of included files to not include this file
- Change one of those TSConfigs to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the typescript-eslint docs for more info: https://typescript-eslint.io/linting/troubleshooting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file

The project does not define parserOptions.project for markdown files https://github.com/snabbdom/snabbdom/blob/master/.eslintrc.json

Would anyone tell me what I'm doing wrong? I've tried explicitly setting null parserOptions.project, but it did not have any effect

{
    "files": ["**/*.md"],
    "processor": "markdown/markdown",
    "parserOptions": {
      "project": null
    }
}

from eslint-plugin-markdown.

iambumblehead avatar iambumblehead commented on May 22, 2024

The issue was resolved by explicitly ignoring README-related files in the eslint typescript configuration. The full PR and changes are here snabbdom/snabbdom#1074

from eslint-plugin-markdown.

meteorlxy avatar meteorlxy commented on May 22, 2024

For flat config, this snippet should help:

{
  files: ['**/*.md/**'],
  languageOptions: {
    parserOptions: {
      project: null,
    },
  },
}

from eslint-plugin-markdown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.