semistandard

repository·master·Indexed 23 days ago

https://github.com/standard/semistandard

A JavaScript linter that provides the 'standard' style rules but enforces the use of semicolons. It includes a CLI for checking code style, support for custom parsers, and integration options for package.json, Vim, and various editor plugins.

Tokens
934
Snippets
7
Records
10
Agent score
31%

What's inside semistandard

  1. Configure semistandard for Vim

    master

    To use semistandard with Vim, install Syntastic and add the following to your .vimrc to enable linting:

    let g:syntastic_javascript_checkers=['standard']
    let g:syntastic_javascript_standard_exec = 'semistandard'

    To enable automatic formatting on save, add these lines to your .vimrc:

    autocmd bufwritepost *.js silent !semistandard % --fix
    set autoread
    let g:syntastic_javascript_checkers=['standard']
    let g:syntastic_javascript_standard_exec = 'semistandard'
    
    autocmd bufwritepost *.js silent !semistandard % --fix
    set autoread
  2. Ignore files and directories in semistandard

    master

    By default, semistandard automatically excludes:

    • node_modules/**
    • *.min.js
    • bundle.js
    • coverage/**
    • Hidden files/folders (starting with . )
    • All patterns in your project's root .gitignore file.

    To ignore additional specific files or folders, add a semistandard.ignore array to your package.json.

    "semistandard": {
      "ignore": [
        "**/out/",
        "/lib/select2/",
        "/lib/ckeditor/",
        "tmp.js"
      ]
    }
  3. Configure semistandard in package.json

    master

    You can integrate semistandard into your project workflow by adding it to your package.json scripts and configuration. This allows you to run style checks automatically during tests (e.g., via npm test).

    Example package.json configuration:

    {
      "name": "my-cool-package",
      "devDependencies": {
        "semistandard": "*"
      },
      "scripts": {
        "test": "semistandard && node my-normal-tests-littered-with-semicolons.js"
      }
    }
  4. Run semistandard to check code style

    master

    Once installed, you can run the semistandard command in your terminal to check the style of all JavaScript files in the current working directory. It will report errors if the code does not adhere to the semi-standard style (which includes all standard/standard rules plus mandatory semicolons).

    $ semistandard
  5. Use semistandard as a StandardEngine instance

    master
    The semistandard package exports a pre-configured instance of StandardEngine. This instance is ready to be used with any tool or runner that supports the standard-engine interface (e.g., standard). It applies the semi-standard ruleset (which includes semicolons) using the provided configuration options.