2.1.2 • Published 2 years ago

eslint-plugin-check-json-value v2.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

eslint-plugin-check-json-value

ESLint plugin to check value of JSON file.

Installation

You'll first need to install ESLint.

npm install --save-dev eslint

Next, install eslint-plugin-check-json-value.

npm install --save-dev eslint-plugin-check-json-value

Usage

Add check-json-value to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix.

{
  "plugins": ["check-json-value"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "check-json-value/json-lint": [
      "error",
      {
        "lint": true
      }
    ],
    "check-json-value/json-value": [
      "error",
      [
        {
          "file": "member-.+\\.json",
          "path": "gender",
          "values": [
            {
              "type": "string",
              "value": "^(fe)?males$"
            }
          ]
        },
        {
          "file": "data/record-201[0-9]\\.json",
          "path": "records[{{COUNTER1}}].items[{{COUNTER2]}}",
          "values": [
            {
              "type": "number",
              "value": "^\\d{4,6}$"
            }
          ],
          "if": [
            {
              "path": "status",
              "values": [
                {
                  "type": "string",
                  "value": "^need confirm$",
                  "ignoreCase": true
                },
                {
                  "type": "string",
                  "value": "^unconfirmed$",
                  "ignoreCase": true
                }
              ]
            },
            {
              "path": "complete",
              "values": [
                {
                  "type": "boolean",
                  "value": true
                }
              ]
            }
          ],
          "for": [
            {
              "replace": "{{COUNTER1}}",
              "start": 0,
              "end": 10,
              "step": 1
            },
            {
              "replace": "{{COUNTER2}}",
              "start": 0,
              "end": 20,
              "step": 10
            }
          ]
        }
      ]
    ]
  }
}

See schemas of rules check-json-value/json-lint and check-json-value/json-value. Also here are examples of usage in unit tests for rules.

LICENSE

MIT License.

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago