Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

pretty-standard

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pretty-standard

All the goodness of standard with the power of prettier formatting.

npmnpm
Version
1.0.0
Version published
Weekly downloads
1
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

pretty-standard

travis npm downloads

JavaScript standard lint rules with prettier style and formatting.

Why?

Write up coming soon.. tl;dr standard is an opinionated linter, prettier is an opinionated formatter. Both tools are great and very comprehensive. All of the eslint, standard and prettier have been engineered impressively well and are very pluggable. This package just puts them all together in a way that works out of the box so you don't have to.

Install

npm install pretty-standard

Rules

All non style related standard rules which leaves code style to prettier. More specifically this package combines the following:

  • eslint-config-standard
  • eslint-config-standard-jsx
  • eslint-config-prettier
  • eslint-plugin-prettier – to format code when using --fix flag

Usage

Install globally or locally with:

npm install pretty-standard
npm install pretty-standard -g

Then run in your project, the typical standard defaults and ignores apply:

$ pretty-standard
pretty-standard: Standard eslint rules with prettier formatting
  pages/index.js:9:3: 'useState' is not defined.

Or pass --fix to format your code using prettier, which will also log the linting errors that can not be fixed by prettier:

$ pretty-standard --fix

Editor plugins

Coming soon to Sublime, VSCode and Atom!

Add it to package.json.

{
  "name": "my-cool-package",
  "devDependencies": {
    "pretty-standard": "*"
  },
  "scripts": {
    "test": "pretty-standard && ava",
    "format": "pretty-standard --fix"
  }
}

Custom Parser

To use a custom parser, install it from npm (example: npm install babel-eslint) and add it to your package.json, this is sometimes necessary when using futuristic JS features:

{
  "pretty-standard": {
    "parser": "babel-eslint"
  }
}

Vim

Install Syntastic and add these lines to .vimrc:

let g:syntastic_javascript_checkers=['standard']
let g:syntastic_javascript_standard_exec = 'pretty-standard'

For automatic formatting on save, add these two lines to .vimrc:

autocmd bufwritepost *.js silent !pretty-standard % --fix
set autoread

Ignoring files

Just like in standard, The paths node_modules/**, *.min.js, bundle.js, coverage/**, hidden files/folders (beginning with .), and all patterns in a project's root .gitignore file are automatically excluded when looking for .js files to check.

Sometimes you need to ignore additional folders or specific minfied files. To do that, add a pretty-standard.ignore property to package.json:

"pretty-standard": {
  "ignore": [
    "**/out/",
    "/lib/select2/",
    "/lib/ckeditor/",
    "tmp.js"
  ]
}

Make it look snazzy

If you want prettier output, install snazzy package and pipe pretty-standard to it:

$ pretty-standard --verbose | snazzy

See standard/standard for more information.

Keywords

JavaScript Standard Style

FAQs

Package last updated on 18 Jan 2019

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