Socket
Socket
Sign inDemoInstall

neostandard

Package Overview
Dependencies
Maintainers
0
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

neostandard

A modern successor to standard


Version published
Weekly downloads
14K
decreased by-10.17%
Maintainers
0
Weekly downloads
 
Created
Source
neostandard

npm version npm downloads neostandard javascript style

A spiritual successor to the standard javascript style guide

Initial development sponsored by:

platformatic

Table of Contents

Quick Start

Migrate from standard

  1. npm install -D neostandard eslint
  2. npx neostandard --migrate > eslint.config.js (uses our config helper)
  3. Replace standard with eslint in all places where you run standard, eg. "scripts" and .github/workflows/ (neostandard CLI tracked in #2)
  4. (Add ESLint editor integration, eg. VS Code ESLint extension)
  5. Cleanup:
    • npm uninstall standard
    • Remove unused "standard" top level key from your package.json
    • Deactivate standard specific integrations if you no longer use them (eg. vscode-standard))

Add to new project

  1. npm install -D neostandard eslint

  2. Add an eslint.config.js:

    Using config helper:

    npx neostandard --esm > eslint.config.js
    

    Or to get CommonJS:

    npx neostandard > eslint.config.js
    

    Or manually create the file as ESM:

    import { neostandard } from 'neostandard'
    
    export default neostandard({
      // options
    })
    

    Or as CommonJS:

    module.exports = require('neostandard')({
      // options
    })
    
  3. Run neostandard by running ESLint, eg. using npx eslint, npx eslint --fix or similar

Configuration options

  • env - string[] - adds additional globals by importing them from the globals npm module
  • files - string[] - additional file patterns to match. Uses the same shape as ESLint files
  • filesTs - string[] - additional file patterns for the TypeScript configs to match. Uses the same shape as ESLint files
  • globals - string[] | object - an array of names of globals or an object of the same shape as ESLint languageOptions.globals
  • ignores - string[] - an array of glob patterns for files that the config should not apply to, see ESLint documentation for details
  • noStyle - boolean - if set, no style rules will be added. Especially useful when combined with Prettier, dprint or similar
  • semi - boolean - if set, enforce rather than forbid semicolons (same as semistandard did)
  • ts - boolean - if set, TypeScript syntax will be supported and *.ts (including *.d.ts) will be checked. To add additional file patterns to the TypeScript checks, use filesTs

Additional exports

resolveIgnoresFromGitignore()

Finds a .gitignore file that resides in the same directory as the ESLint config file and returns an array of ESLint ignores that matches the same files.

ESM:

import neostandard, { resolveIgnoresFromGitignore } from 'neostandard'

export default neostandard({
  ignores: resolveIgnoresFromGitignore(),
})

CommonJS:

module.exports = require('neostandard')({
  ignores: require('neostandard').resolveIgnoresFromGitignore(),
})

Exported plugins

neostandard exports all the ESLint plugins that it uses. This to ensure that users who need to reference the plugin themselves will use the exact same instance of the plugin, which is a necessity when a plugin prefix is defined in multiple places.

List of exported plugins
Usage of exported plugin

If one eg. wants to add the eslint-plugin-n recommended config, then one can do:

import neostandard, { plugins } from 'neostandard'

export default [
  ...neostandard({
    ignores: resolveIgnoresFromGitignore(),
  }),
  plugins.n.configs['flat/recommended'],
]

Missing for 1.0.0 release

  • Add JSX/TSX support: #11
  • Migrate eslint-plugin-import rules from standard: #15
  • Investigate a dedicated neostandard runner: #33 / #2

Full list in 1.0.0 milestone

Differences to standard / eslint-config-standard 17.x

Changed rules

  • @stylistic/comma-danglechanged – set to prefer dangling commas in everything but functions and is it set to warn rather than error

Relaxed rules

Missing bits

  • Some plugins are not yet supporting ESLint 9 or flat configs and has thus not yet been added. These are:
    • eslint-plugin-import
  • JSX parsing is not supported out of the box

Config helper

You can use the provided CLI tool to generate a config for you:

neostandard --semi --ts > eslint.config.js

To see all available flags, run:

neostandard --help

Config migration

The CLI tool can also migrate an existing "standard" configuration from package.json:

neostandard --migrate > eslint.config.js

Migrations can also be extended, so to eg. migrate a semistandard setup, do:

neostandard --semi --migrate > eslint.config.js

Readme badges

Yes! If you use neostandard in your project, you can include one of these badges in your readme to let people know that your code is using the neostandard style.

neostandard javascript style

[![neostandard javascript style](https://img.shields.io/badge/neo-standard-7fffff?style=flat&labelColor=ff80ff)](https://github.com/neostandard/neostandard)

neostandard javascript style

[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-7fffff?style=flat&labelColor=ff80ff)](https://github.com/neostandard/neostandard)

neostandard javascript style

[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)

FAQs

Package last updated on 01 Jul 2024

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc