parcel-plugin-tslint

0.0.2 • Public • Published

parcel-plugin-tslint NPM version shield

A Parcel plugin for running tslint.

Screenshot showing parcel-plugin-tslint output

Install

# Ensure that you have peer dependencies installed first...
npm install --save parcel-bundler typescript tslint

# ...then install the plugin.
npm install --save-dev parcel-plugin-tslint

Usage

Create a tslint.json file, per the tslint configuration docs. You can customize how the linter output is displayed by adding a custom formatter setting to the linterOptions property. Example:

"linterOptions": {
    // See https://palantir.github.io/tslint/formatters/ for full list of formatters
    "formatter": "stylish"
}

To disable linting (e.g., while making a production bundle) run with the DISABLE_PARCEL_TSLINT_PLUGIN environment variable. Example:

// package.json
...
"script" {
  "bundle": "DISABLE_PARCEL_TSLINT_PLUGIN=true parcel build src/index.html"
}

Example

Clone this repo and run npm run testWatch or see the whole thing in action in your browser here: https://codesandbox.io/s/1ryv0o467

Release Notes

  • 0.0.1 WIP
  • 0.0.2 Fix for #3 (thanks @teroyks!), upgraded to Parcel 1.11.

Dependencies

Regular

  • strip-json-comments makes it easier to parse tslint.json (which can have comments).

Peer

parcel-plugin-tslint assumes that you're already bringing the following to the party:

  • parcel-bundler 1.x (tested with 1.11)
  • tslint 5.x (tested with 5.11)
  • typescript

Dev

  • @types/node allowed IDEs such as VSCode to be aware of Node's API (i.e., to support "intellisense" features for core Node objects such as 'fs').

Contributing

See CONTRIBUTING

Credits

TODO

  • Add a mocha test that uses the bundler output checker

  • Add to https://github.com/parcel-bundler/awesome-parcel

  • Mention in https://github.com/fathyb/parcel-plugin-typescript/issues/51#issuecomment-407219283

  • Do a better job of detecting and reporting error if/when tslint depdendency can't be found. Exmple output:

      $ npm run serve
    
    > unstated-counter@0.0.1 serve /Users/c/projects/@clinthharris/unstated-counter
    > parcel --no-cache --no-autoinstall -p 1234 src/index.html
    
    Server running at http://localhost:1234
    🚨  /Users/c/projects/@clinthharris/unstated-counter/src/index.tsx: Cannot resolve dependency './state/CounterState' at '/Users/c/projects/@clinthharris/unstated-counter/src/state/CounterState'
        at Function.Module._resolveFilename (module.js:548:15)
        at Function.Module._load (module.js:475:25)
        at Module.require (module.js:597:17)
        at require (/Users/c/projects/@clinthharris/unstated-counter/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
        at Object.<anonymous> (/Users/c/projects/@clinthharris/unstated-counter/node_modules/parcel-plugin-tslint/src/TslintAsset.js:2:16)
    

    The error says Cannot resolve dependency './state/CounterState' but it's actually coming from TslintAsset.js:2:16 which is require('tslint');

Readme

Keywords

none

Package Sidebar

Install

npm i parcel-plugin-tslint

Weekly Downloads

3

Version

0.0.2

License

MIT

Unpacked Size

10.3 kB

Total Files

13

Last publish

Collaborators

  • clintharris