npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-twig

v0.1.5

Published

This plugin treats Twig template expressions as Javascript literals and ignores template statements and comments.

Readme

eslint-plugin-twig

This plugin treats Twig template expressions and statements as valid Javascript expressions, so that ESLint can check javascript code, ignoring any Jinja expression found.

Obvious statement

It is highly recommended to avoid using plain JavaScript in Twig templates, and rely on standard WebPack mechanics to process and to optimized JavaScript code. However, in some legacy Symfony applications, JavaScript is present "en masse" in Twig templates, being html templates or templates generating JavaScript. This plug aims at processing this code

Work in progress

This plugin is still being developed and tested

Usage

Simply install this plugin along with the esling-plugin-html one via npm install --save-dev eslint-plugin-html eslint-plugin-twig and add the plugin to your ESLint configuration. See ESLint documentation.

import html from "eslint-plugin-html"

export default [
  {
    files: ["**/*.html"],
    plugins: { html, twig },
    processor: "twig/ twig",
},
]
{
  "plugins": ["html", "twig"]
}

Disabling ESLint

To temporarily disable ESLint, use the <!-- eslint-disable --> HTML comment. Re-enable it with <!-- eslint enable -->. Example:

<!-- eslint-disable -->
<script>
  var foo = 1
</script>
<!-- eslint-enable -->

To disable ESLint for the next script tag only, use the <!-- eslint-disable-next-script --> HTML comment. Example:

<!-- eslint-disable-next-script -->
<script>
  var foo = 1
</script>

Disabled script tags are completely ignored: their content will not be parsed as JavaScript. You can use this to disable script tags containing template syntax.

Troubleshooting

By placing the following statement in your .twig file, the preprocessed output will be sent to the console when linting. This can be convenient to catch specific problems.

<script>
    // eslint-plugin-twig debug
</script>

Known issues

Prettier fixes won't be applied

If you are processing Twig templates as HTML files, then your Javascript segments shouldn't follow the Twig indentation but start from the left as if it was a regular .js file.

<script>
// Do this
</script>
    <script>
    // Not this
    </script>

Unreachable code

<script>
{% if someCondition %}
  return something;
{% else %}
  return somethingElse; // This line will trigger the unreachable rule - use eslint-disable-link
{% endif %}
</script>