Package detail

ts-standardx

exuanbo703MIT0.8.4

Yet another configurable linter for TypeScript and JavaScript.

standard, standardx, ts-standard, typescript

readme

ts-standardx

Yet another configurable linter for TypeScript and JavaScript.

npm GitHub Workflow Status (branch) Codecov branch libera manifesto

🚀 Features

Todo

💾 Install

npm install --save-dev ts-standardx

🤖 CLI

$ npx ts-standardx

To enable auto fix and format, use --fix.

$ npx ts-standardx --fix

To lint text from stdin, use - or --stdin.

$ echo "const greet = ( ) => 'hi'" | npx ts-standardx -
<summary>output</summary>

<text>:1:7 error 'greet' is assigned a value but never used. no-unused-vars <text>:1:17 error Delete `·` prettier/prettier Run `ts-standardx --fix` to automatically fix some problems.


Add --fix to output fixed text.

$ echo "const greet = ( ) => 'hi'" | npx ts-standardx - --fix
<summary>output</summary>

const greet = () => 'hi'

--help

ts-standardx: Yet another configurable linter for TypeScript and JavaScript. (https://github.com/exuanbo/ts-standardx#readme)

Usage: ts-standardx <flags> [FILES...]

  If FILES is omitted, all source files (*.ts, *.tsx, *.js, *.jsx, *.mjs, *.cjs)
  in the current working directory will be checked recursively.

  By default, files/folders that begin with '.' like .eslintrc .cache/ and
  paths in .gitignore are automatically ignored.

Basic:
  --fix                Automatically fix problems

Config:
  --env                Use custom eslint environment
  --ext                Specify file extensions
  --global             Declare global variable
  --parser             Use custom parser (e.g. babel-eslint)
  --plugin             Use custom eslint plugin

Input:
  --stdin              Read file text from stdin
  --disable-gitignore  Disable use of .gitignore by default

Misc:
  -h, --help           Show usage information
  -v, --version        Show current version

⌨️ API

<summary>Check</summary>

ts // index.d.ts import { ProvidedOptions, Linter as __Linter, CLI as __CLI } from 'standard-engine-ts' declare const options: ProvidedOptions declare class Linter extends __Linter { constructor(customOptions?: ProvidedOptions) } declare class CLI extends __CLI { constructor(customOptions?: ProvidedOptions) } export { CLI, Linter, options }

⚙️ Configuration

ts-standardx uses .eslintrc* from the current working directory.

Note that rules for TypeScript need to be placed in overrides as example below.

// .eslintrc.js

module.exports = {
  overrides: [
    {
      files: ['**/*.ts', '**/*.tsx'],
      rules: {
        '@typescript-eslint/no-explicit-any': 'off'
      }
    }
  ]
}

.prettierrc* will be read from the current directory, but these options

  • semi
  • singleQuote
  • trailingComma
  • bracketSameLine
  • arrowParens

will not take effect. The only way to change them is setting in .eslintrc* as example below.

// .eslintrc.js

module.exports = {
  rules: {
    'prettier/prettier': ['error', { ...options }]
  }
}

Editor extension

Add the default config to extends to use the official ESLint extension.

// .eslintrc.js

module.exports = {
  extends: ['./node_modules/ts-standardx/.eslintrc.js']
}
<summary>But wait a second...</summary>

"So why can't I use npx eslint . directly?" Yes, you can :p

🔎 Details

This package includes:

  • @typescript-eslint/eslint-plugin
  • @typescript-eslint/parser
  • eslint
  • eslint-config-prettier
  • eslint-config-standard
  • eslint-config-standard-jsx
  • eslint-plugin-import
  • eslint-plugin-node
  • eslint-plugin-prettier
  • eslint-plugin-promise
  • eslint-plugin-react
  • prettier
  • standard-engine-ts

eslintrc.ts

<summary>Check</summary>

ts import type { Linter } from 'eslint' import { rules } from './rules' import { prettierCompatRules, compatRules, prettierTypescriptCompatRules } from './compatRules' import { isModuleAvailable } from './utils' const PRETTIER_STANDARD = { semi: false, singleQuote: true, trailingComma: 'none', bracketSameLine: true, arrowParens: 'avoid' } const eslintrc: Linter.BaseConfig = { extends: ['standard', 'standard-jsx', 'prettier'], plugins: ['prettier'], rules: { 'prettier/prettier': ['error', PRETTIER_STANDARD], ...prettierCompatRules }, overrides: isModuleAvailable('typescript') ? [ { files: ['**/*.ts', '**/*.tsx'], extends: ['plugin:@typescript-eslint/recommended'], rules: { ...rules, ...compatRules, ...prettierTypescriptCompatRules } } ] : undefined } export default eslintrc

🤔 Why

Todo

📃 Todo

  • [ ] Document
  • [ ] Allow specify parserOptions.project
  • [ ] Remove eslint-config-standard-jsx

License

MIT License © 2021 Exuanbo

changelog

Changelog

0.8.4 (2021-10-05)

Chores

  • Bump dependency versions.

0.8.3 (2021-09-27)

Chores

  • Bump dependency versions.

0.8.2 (2021-09-22)

Code Refactoring

  • eslintrc: Remove redundant option parser: '@typescript-eslint/parser'

Chores

  • Bump dependency versions.

0.8.1 (2021-09-15)

Fixes

  • prettier option jsxBracketSameLine is renamed to bracketSameLine from version 2.4.0

Chores

  • Bump dependency versions.

0.8.0 (2021-08-31)

Features

  • Loose rule @typescript-eslint/naming-convention to allow double underscore.

Chores

  • Bump dependency versions.
  • Change generated code from es2015 to es2019.