Git Product home page Git Product logo

Comments (6)

edi9999 avatar edi9999 commented on June 5, 2024

To make this work, it would have to parse the HTML tag and extract all inline script tags, and analyse the content of those script tags.

from eslint-plugin-markdown.

mdjermanovic avatar mdjermanovic commented on June 5, 2024

Hi @edi9999, thanks for the issue!

To make this work, it would have to parse the HTML tag and extract all inline script tags, and analyse the content of those script tags.

eslint-plugin-markdown only extracts markdown code blocks. To additionally extract JS from HTML code blocks, you can use eslint-plugin-html.

Here's an example of config file that uses both plugins:

// .eslintrc.js
module.exports = {
    plugins: ["markdown", "html"],
    overrides: [
        {
            // use markdown processor on .md files
            files: ["**/*.md"],
            processor: "markdown/markdown"
        },
        {
            // add extracted html code blocks as lint targets, eslint-plugin-html will automatically pick them
            files: ["**/*.md/*.html"],
        }
    ],

    // your configuration
    rules: {
        "no-undef": 2
        // ...
    }
};

from eslint-plugin-markdown.

edi9999 avatar edi9999 commented on June 5, 2024

Does this work out of the box ?

from eslint-plugin-markdown.

edi9999 avatar edi9999 commented on June 5, 2024

I mean you have written in your code files: ["**/*.md/*.html"],, does that mean I have to manually extract my HTML samples to make your suggestion work ?

from eslint-plugin-markdown.

mdjermanovic avatar mdjermanovic commented on June 5, 2024

I mean you have written in your code files: ["**/*.md/*.html"],, does that mean I have to manually extract my HTML samples to make your suggestion work ?

This should "just work". ESLint treats extracted code blocks as virtual files (e.g., foo.md/0.html, foo.md/1.html...) and lints them as if they were real files. I've just tried the above config with your example and got:

  25:13  error  'PizZipUtils' is not defined  no-undef
  27:9   error  'window' is not defined       no-undef
  34:35  error  'PizZip' is not defined       no-undef
  35:35  error  'window' is not defined       no-undef
  57:21  error  'saveAs' is not defined       no-undef

from eslint-plugin-markdown.

edi9999 avatar edi9999 commented on June 5, 2024

It worked very well for me !

Thanks a lot !

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.