Socket
Book a DemoInstallSign in
Socket

jsonld-lint

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonld-lint

JSON-LD Linter

0.3.0
latest
Source
npmnpm
Version published
Weekly downloads
5
400%
Maintainers
1
Weekly downloads
 
Created
Source

Mattr logo

JSON-LD Lint

npm-version npm-unstable-version push-master push-release

This package contains the core JSON-LD lint engine written in typescript its primary dependencies are

Syntax Errors

The following defines the different types of syntax errors the processing engine detects, if a syntax error is encountered subsequent processing of the document terminates.

Unexpected JSON-LD Keyword Value Type

Rule - jsonld-lint/unexpected-json-value-type

A result of this type will be returned when an unexpected value type for a JSON-LD keyword is encountered.

Example - Invalid as the expected JSON value types for @context are string, array or object.

{
  "@context": false
}

Unexpected JSON-LD Keyword Value

Rule - jsonld-lint/unexpected-json-value

A result of this type will be returned when an unexpected value for a JSON-LD keyword is encountered.

Example - Invalid as the expected values for @version are 1, 1.0 and 1.1.

{
  "@version": 25
}

Unexpected use of JSON-LD keyword

Rule - jsonld-lint/unexpected-use-of-jsonld-keyword

A result of this type will be returned when a JSON-LD keyword is used in an unexpected way.

Example - Invalid as @base is not valid inside a node object only in a local context definition.

{
  "@base": "https://example.com"
}

Duplicate key in JSON object

Rule - jsonld-lint/duplicate-json-key

A result of this type will be return when an object/map within a JSON-LD document is encountered that features duplicate property keys, which is illegal in JSON-LD.

Example - Invalid as the test property key is repeated.

{
  "test": true,
  "test": false
}

Duplicate aliased JSON-LD keyword

Rule - jsonld-lint/duplicate-alias-jsonld-keyword

A result of this type will be return when an object/map within a JSON-LD document has the aliased equivalent properties both featured in the same JSON object.

Example - Invalid as id is an alias of the JSON-LD keyword @id.

{
  "id": "test-id",
  "@id": "test-id"
}

Invalid JSON-LD keyword as term value

Rule - jsonld-lint/invalid-jsonld-keyword-as-term-value

A result of this type will be returned when a JSON value type of string is encountered where the value matches a JSON-LD keyword being used in an invalid manner.

Example - Invalid when a JSON property has a string value of @context because it is a JSON-LD keyword, @type is the only JSON-LD keyword allowed.

{
  "property": "@context"
}

Linting Rules

The following defines the different types of linting results the processing engine detects.

Unrecognized JSON-LD keyword

Rule - jsonld-lint/unrecognized-jsonld-keyword

JSON-LD keywords use the common pattern of featuring the @ as a prefix, to ensure preservation of the namespace and allow future versions of JSON-LD to define new terms, developers are encourage to not feature JSON properties where the key is prefixed with an @ symbol and it is not defined by JSON-LD.

Example - The JSON key of @this-is-a-test matches the convention of being a JSON-LD term but is not a JSON-LD term.

{
  "@this-is-a-test": true
}

Un-mapped Term

Rule - jsonld-lint/unmapped-term

A result of this type will be returned when expansion of a term fails. This is usually due to the term not being documented in the documents context.

Example - The term undefinedTerm is not defined in the documents context, hence will be reported as an un-mapped term.

{
  "@context": {
    "definedTerm": "https://example.com/definedTerm"
  },
  "definedTerm": "good",
  "undefinedTerm": "bad"
}

Empty JSON Property Key

Rule - jsonld-lint/empty-json-property-key

A result of this type will be returned when a JSON property key is encountered which is an empty string

Example - The JSON object contains an empty string as the key for one of the JSON properties

{
  "@context": {},
  "": false
}

FAQs

Package last updated on 29 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.