GithubHelp home page GithubHelp logo

danielrentz / eslint-plugin-json-es Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zeitport/eslint-plugin-json-es

0.0 0.0 0.0 306 KB

A ESLint plugin to lint JSON.

License: MIT License

JavaScript 100.00%

eslint-plugin-json-es's Introduction

NPM version CI status CodeQL

eslint-plugin-json-es

A JSON parser for ESLint that works with a lot of existing ESLint rules or your custom rules.

Installation

npm install eslint-plugin-json-es --save-dev

Configure ESLint

This is an example ESLint configuration for all *.json files. It extends the recommended rules for JSON.

{
    "overrides": [{
        "files": ["*.json"],
        "parser": "eslint-plugin-json-es",
        "extends": "plugin:eslint-plugin-json-es/recommended",
        "rules": {
        }
    }]
}

Examples

See the example branch for different use cases and ESLint configurations.

Alternative JSON Plugins

There are three different ways how to add JSON linting to ESLint. Select the package that fits your needs:

eslint-plugin-json-es eslint-plugin-json eslint-plugin-jsonc
Version NPM version NPM version NPM version
Engine ESLint espree parser VSCode JSON Validation Custom AST parser
ESLint version >7.0.0 ? >6.0.0
Custom rules ✔ (1)
Use existing ESLint rules ✔ (2)
Fix Code ✔ (partly)
Rule compare guide - Compare #TODO :-(

(1) Uses custom AST node types
(2) Not every ESLint rule makes sense for JSON

Rules Configurations

Recommended

./config/recommended.js

Auto-fix Rule Version
🔧 comma-dangle > 1.3.0
no-dupe-keys > 1.3.0
🔧 no-extra-parens > 1.4.0
no-irregular-whitespace > 1.3.0
no-loss-of-precision > 1.3.0
no-undefined > 1.3.0
🔧 quotes > 1.3.0
🔧 quote-props > 1.3.0

Readable

Based on the recommended rules with stylistic aspects.

./config/readable.js

Auto-fix Rule Comment
🔧 indent 4
🔧 no-multiple-empty-lines
sort-keys Alternative with fix eslint-plugin-sort-keys-fix

eslint-plugin-json-es's People

Contributors

cschuller avatar edg2s avatar dependabot[bot] avatar

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.