Package Exports
- ts-standardx
- ts-standardx/.eslintrc.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ts-standardx) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
> Yet another customizable linter for TypeScript and JavaScript.
๐ Features
Todo
๐พ Install
npm install --save-dev ts-standardx
๐ IDE extension
Install the official eslint
extension, then add a config file in the project root directory as example below. Your custom config will be deeply merged into the base .eslintrc.js
(See #Details).
// .eslintrc.js
const { mergeObj } = require('standard-engine-ts')
const baseConfig = require('ts-standardx/.eslintrc.js')
module.exports = mergeObj(baseConfig, {
/* Your custom config */
})
// Or simply use the default config
module.exports = require('ts-standardx/.eslintrc.js')
If you don't like being blamed while coding ๐คฏ, there is no need to export require('ts-standardx/.eslintrc.js')
. Just write your ESLint config as usual and it will be merged automatically.
๐ค 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 salute = ( ) => 'hi'" | npx ts-standardx -
output
ts-standardx: Yet another customizable Standard for TypeScript. (https://github.com/exuanbo/ts-standardx#readme)
Run `ts-standardx --fix` to automatically fix some problems.
<text>:1:19: Delete `ยท`
Add --fix
to output fixed text.
$ echo "const salute = ( ) => 'hi'" | npx ts-standardx - --fix
output
export const a = () => 'hello'
--help
ts-standardx: Yet another customizable 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 the project's root .gitignore are automatically ignored.
Basic:
--fix Automatically fix problems
--verbose Show rule names for errors (to ignore specific rules)
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
// index.d.ts
import { ProvidedOptions, Linter, CLI } from 'standard-engine-ts'
declare const opts: ProvidedOptions
declare const linter: Linter
declare const cli: CLI
export { cli, linter, opts }
๐ 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.js
const path = require('path')
module.exports = {
extends: [
'plugin:react/recommended',
'standard',
'standard-jsx',
'plugin:prettier/recommended',
'prettier/react',
'prettier/standard'
],
overrides: [
{
files: ['**/*.ts', '**/*.tsx'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier/@typescript-eslint'
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: path.join(process.cwd(), 'tsconfig.json')
}
}
],
plugins: ['prettier'],
rules: {
'prettier/prettier': ['error', require('./.prettierrc.js')]
}
}
.prettierrc.js
module.exports = {
arrowParens: 'avoid',
bracketSpacing: true,
jsxBracketSameLine: true,
semi: false,
singleQuote: true,
tabWidth: 2,
trailingComma: 'none'
}
๐ค Why
Todo
๐ Todo
- Unit testing
- Documentation
- Prettier output
- Better intergration with Prettier
License
MIT License ยฉ 2020 Exuanbo