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

rollup-plugin-jsonlint

v2.0.3

Published

Converts .json (JSON/CJSON/JSON5) files to ES6 modules.

Downloads

15

Readme

rollup-plugin-jsonlint

Latest version Dependency status Code coverage

A Rollup plugin which converts .json files to ES6 modules. Recognizes standard JSON, CJSON (JSON with comments) and JSON5 (further more flexible JSON).

This plugin started as an overwrite of @rollup/plugin-json. It supports all the original options. It leverages the parser from @prantlf/jsonlint to provide better error information in case or invalid input and to parse JSON extensions like CJSON and JSON5. If no extension is enabled, the standard JSON.parse will be used for the best performance.

Requirements

This plugin requires Node.js LTS (currently 18, at least 14.8) and Rollup 1.20 or newer.

Installation

Using npm:

npm i -D rollup-plugin-jsonlint

Usage

Create a rollup.config.js configuration file and import the plugin:

import jsonlint from 'rollup-plugin-jsonlint'

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [jsonlint({ mode: 'cjson' })]
}

Then call rollup either via the command-line or the programmatically.

With an accompanying file src/index.js, the local package.json file would now be importable as seen below:

import pkg from './package.json';
console.log(`Running version ${pkg.version}.`);

Input Parsing Options

The following options customize the parser. If no default value is changed, only the standard JSON will be accepted.

mode

Type: String (json|cjson|json5) Default: json

A shortcut for setting the three boolean flags below.

  • json - expects the standard JSON (uses defaults)
  • cjson - expects CJSON (sets ignoreComments to true)
  • json5 - expects JSON5 (sets ignoreComments, ignoreTrailingCommas and allowSingleQuotedStrings to true)

ignoreBOM

Type: Boolean Default: false

If true, the leading UTF-8 byte-order mark will be ignored.

ignoreComments

Type: Boolean Default: false

If true, single-line and multi-line JavaScript-style comments will be ignored as another "whitespace". (CJSON and JSON5 feature)

ignoreTrailingCommas

Type: Boolean Default: false

If true, trailing commas after the last object entry and array items will be ignored without throwing an error. (JSON5 feature)

allowSingleQuotedStrings

Type: Boolean Default: false

If true, single quotes will be accepted in addition to double quotes as characters for enclosing string literals within. (JSON5 feature)

allowDuplicateObjectKeys

Type: Boolean Default: true

If false, duplicate object keys will be reported as an error. Useful for detecting mistakes in configuration files, where duplicate keys usually mean old properties forgotten to be deleted.

Module Generation Options

The following options customize the ES6 module generator.

compact

Type: Boolean Default: false

If true, instructs the plugin to ignore indent and generate the smallest code.

exclude

Type: String | Array[...String] Default: null

A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should ignore. By default no files are ignored.

include

Type: String | Array[...String] Default: null

A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should operate on. By default all files are targeted.

indent

Type: String Default: '\t'

Specifies the indentation for the generated default export.

namedExports

Type: Boolean Default: true

If true, instructs the plugin to generate a named export for every property of the JSON object.

preferConst

Type: Boolean Default: false

If true, instructs the plugin to declare properties as variables, using either var or const. This pertains to tree-shaking.

License

Copyright (C) 2019-2024 Ferdinand Prantl

Licensed under the MIT License.