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 🙏

© 2024 – Pkg Stats / Ryan Hefner

any-eslint-parser

v1.0.1

Published

Check Any file with ESLint

Downloads

7,200

Readme

any-eslint-parser any-eslint-parser  License Github repo Gitlab repo


Quick Start

1 . Add dependencies:

package.json:

  ..
  "devDependencies": {
    "any-eslint-parser": "1.0.0",
    "eslint": "*",

2 . Configure eslint with the required rules, e.g. eol-last and no-tabs:

.eslintrc-any.json:

{
  "parser": "any-eslint-parser",
  "rules": {
    "eol-last": "error",
    "no-tabs": "error"
  }
}

Any eslint rule that not required AST can be used, this example uses eol-last and no-tabs.

3 . Configure linting script:

package.json:

  "scripts": {
    "lint.any": "eslint --config .eslintrc-any.json \"**/*.+(js|jsx|ts|tsx|json|yml|xml|sh|txt|md|svg|properties|gradle|java|cpp|c|html|css|groovy|gitignore|npmignore)\"",

Goals

any-eslint-parser provides a parser so "any" type of file can be checked by eslint. Although eslint claims to be AST-based, there are rules that does not based on AST, rather they are based on the text content of the file, e.g. eol-last, no-tabs, eslint-plugin-regex, etc. any-eslint-parser can be used to check json files, yaml files, script files, source code files in any programming language (e.g. java, c++, groovy, etc.), svg files, markdown files, etc.

any-eslint-parser

This idea arise from the need to use eslint-plugin-regex in other type of files, besides javascript. (Then saw on this as a more versatile and configurable way to check common files than using lintspaces)

  • Rules that required AST will simply be ignored, i.e. no error will be reported.
    • Neither the list of eslint rules, nor rules description provide explicit information on whether they need AST or not, so, You may need to test the rules before using, or use regex rules aka eslint-plugin-regex.
  • Cascading and Hierarchy of ESlint Configuration files are still applied.

Examples

Replacing lintspaces

.eslintrc-any.json

  {
    "parser": "any-eslint-parser",
    "rules": {
      "eol-last": "error",
      "no-tabs": "error"
    }
  }

package.json:

  "scripts": {
    "lint.any": "eslint --config .eslintrc-any.json \"**/[\\.a-zA-Z]*.+(js|jsx|ts|tsx|json|yml|xml|sh|txt|md|svg|properties|gradle|java|cpp|c|html|css|groovy)\" \"**/.+(|gitignore|npmignore)\" --no-eslintrc --ignore-pattern \"build\""
  },
  "devDependencies": {
    "any-eslint-parser": "1.0.0",
    "eslint": "*"
  }

More detail at Migrating to eslint/any-eslint-parser from lintspaces.

Using eslint-plugin-regex

Requiring Copyright and License on every source file of a project.

.eslintrc-any.json

  {
    "plugins": ["regex"],
    "parser": "any-eslint-parser",
    "rules": {
      "regex/required": [
        "error", [
          "^(?:(?:\\/\\/)|#) Copyright \\(c\\) Super Team",
          "^(?:(?:\\/\\/)|#) Licensed under the MIT License \\(MIT\\), see LICENSE.txt"
        ]
      ]
    }
  }

package.json:

  "scripts": {
    "lint.any": "eslint --config .eslintrc-any.json \"**/*.+(js|jsx|ts|tsx|gradle|java|cpp|c|groovy|yml|sh)\""
  },
  "devDependencies": {
    "any-eslint-parser": "1.0.0",
    "eslint": "*",
    "eslint-plugin-regex": "*"
  }

More regex rules examples at eslint-plugin-regex and eslint-plugin-base-style-config regex rules.


Prerequisites


Contributing

License

MIT License


Remember

  • Use code style verification tools => Encourages Best Practices, Efficiency, Readability and Learnability.
  • Code Review everything => Encourages Functional suitability, Performance Efficiency and Teamwork.
  • If viable, Start testing early => Encourages Reliability and Maintainability.

Additional words

Don't forget:

  • Love what you do.
  • Learn everyday.
  • Learn yourself.
  • Share your knowledge.
  • Think different!.
  • Learn from the past, dream on the future, live and enjoy the present to the max!.
  • Enjoy and Value the Quest (It's where you learn and grow).

At life:

  • Let's act, not complain.
  • Be flexible.

At work:

  • Let's give solutions, not questions.
  • Aim to simplicity not intellectualism.