Skip to content

Commit

Permalink
feat: rewrite to follow other standard engines usage (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
theoludwig committed Oct 3, 2022
1 parent 76a887e commit c3de7fe
Show file tree
Hide file tree
Showing 64 changed files with 369 additions and 3,565 deletions.
1 change: 1 addition & 0 deletions .commitlintrc.json
@@ -0,0 +1 @@
{ "extends": ["@commitlint/config-conventional"] }
17 changes: 0 additions & 17 deletions .github/workflows/commitlint.yml

This file was deleted.

31 changes: 6 additions & 25 deletions .github/workflows/nodejs.yml
Expand Up @@ -7,18 +7,15 @@ on:
branches: [master]

jobs:
build:
tests:
runs-on: 'ubuntu-latest'

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]

steps:
- name: 'Checkout Project'
uses: 'actions/checkout@v2.4.0'
with:
fetch-depth: 0
- uses: 'actions/checkout@v3.0.0'

- name: Use Node.js ${{ matrix.node-version }}
uses: 'actions/setup-node@v3.4.1'
Expand All @@ -28,23 +25,7 @@ jobs:
- name: 'Install Dependencies'
run: 'npm install'

- name: Lint Files
run: 'npm run lint'

- name: 'Run Tests and Coverage'
env:
CI: true
run: 'npm run coverage'

- name: 'Coveralls Parallel'
uses: 'coverallsapp/github-action@master'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true
path-to-lcov: './coverage/lcov.info'

- name: 'Coveralls Finished'
uses: 'coverallsapp/github-action@master'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
- run: 'npm run lint:commit -- --to "${{ github.sha }}"'
- run: 'npm run lint:standard'
- run: 'npm run lint:ts-standard'
- run: 'npm run test'
4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

6 changes: 0 additions & 6 deletions .husky/pre-commit

This file was deleted.

2 changes: 1 addition & 1 deletion .npmrc
@@ -1 +1 @@
package-lock = false
package-lock=false
4 changes: 0 additions & 4 deletions .prettierignore

This file was deleted.

9 changes: 8 additions & 1 deletion CHANGELOG.md
@@ -1,6 +1,13 @@
# Changelog

## 12.0.0 - Pending
## 13.0.0 - Pending

## 12.0.0

- **BREAKING:** Major rewrite of `ts-standard` to follow the structure of other `standard` engines (like `standard`, `semistandard`, `standardx`).
- **BREAKING**: Updated `eslint-config-standard-with-typescript` to version `^23.0.0`. Please visit their github page for any style/linter changes.
- **BREAKING**: Dropped support for many options (e.g: `--cwd`), these options should now be implemented in `standard-engine`.
- **BREAKING**: Dropped support for multiple tsconfig projects to be used (need to be rethought, please open an issue, if you really need this feature, explaining why you need this use case).

## 11.0.0

Expand Down
78 changes: 27 additions & 51 deletions README.md
@@ -1,9 +1,8 @@
[![Tests](https://github.com/standard/ts-standard/workflows/tests/badge.svg?branch=master)](https://github.com/standard/ts-standard/actions?query=workflow%3A%22tests%22)
[![Coverage Status](https://coveralls.io/repos/github/standard/ts-standard/badge.svg?branch=master)](https://coveralls.io/github/standard/ts-standard?branch=master)
[![npm](https://badgen.net/npm/v/ts-standard)](https://www.npmjs.com/package/ts-standard)
[![npm](https://badgen.net/npm/dm/ts-standard)](https://www.npmjs.com/package/ts-standard)
[![License](https://badgen.net/github/license/standard/ts-standard)](https://github.com/standard/ts-standard/blob/master/LICENSE)
[![TS-Standard - Typescript Standard Style Guide](https://badgen.net/badge/code%20style/ts-standard/blue?icon=typescript)](https://github.com/standard/ts-standard)
[![TS-Standard - TypeScript Standard Style Guide](https://badgen.net/badge/code%20style/ts-standard/blue?icon=typescript)](https://github.com/standard/ts-standard)
[![Dependabot badge](https://badgen.net/github/dependabot/standard/ts-standard?icon=dependabot)](https://dependabot.com/)

# ts-standard
Expand All @@ -12,7 +11,7 @@ TypeScript Style Guide, with linter and automatic code fixer based on [StandardJ

## 💾 Install

`npm install ts-standard`
`npm install --save-dev ts-standard`

## ⌨️ Basic Usage

Expand All @@ -33,28 +32,33 @@ section below for more details
## 📜 Help

```text
ts-standard - Standard for Typescript! (https://github.com/standard/ts-standard)
ts-standard - Standard for TypeScript! (https://github.com/standard/ts-standard)
Usage:
ts-standard <flags> [FILES...]
If FILES is omitted, all JavaScript/Typescript source files (*.js, *.jsx, *.mjs, *.cjs, *.ts)
in the current working directory are checked, recursively.
Certain paths (node_modules/, coverage/, vendor/, *.min.js, bundle.js, and
files/folders that begin with '.' like .git/) are automatically ignored.
Paths in a project's root .gitignore file are also automatically ignored.
ts-standard <flags> [FILES...]
If FILES is omitted, all JavaScript/TypeScript source files (*.js, *.jsx, *.mjs, *.cjs, *.ts, *.tsx)
in the current working directory are checked, recursively.
Certain paths (node_modules/, coverage/, vendor/, *.min.js, and
files/folders that begin with '.' like .git/) are automatically ignored.
Paths in a project's root .gitignore file are also automatically ignored.
Flags:
--fix Automatically fix problems
-p, --project Specify ts-config location (default: ./tsconfig.eslint.json or ./tsconfig.json)
--version Show current version
-h, --help Show usage information
--fix Automatically fix problems
-p, --project Specify ts-config location (default: ./tsconfig.eslint.json or ./tsconfig.json)
--version Show current version
-h, --help Show usage information
Flags (advanced):
--stdin Read file text from stdin
--globals Declare global variable
--plugins Use custom eslint plugin
--envs Use custom eslint environment
--parser Use custom ts/js parser (default: @typescript-eslint/parser)
--report Use a built-in eslint reporter or custom eslint reporter (default: standard)
--ext, --extensions List of files extensions to lint by default (default: js,jsx,ts,tsx,mjs,cjs)
--stdin Read file text from stdin
--ext Specify JavaScript/TypeScript file extensions
--global Declare global variable
--plugin Use custom eslint plugin
--env Use custom eslint environment
--parser Use custom ts/js parser (default: @typescript-eslint/parser)
```

## 🧬 TSConfig: Linting with Type Information
Expand All @@ -75,14 +79,9 @@ the `--project` flag or adding a `ts-standard` configuration property to your `p
}
```

Its possible to specify multiple projects using an array as in the underlying
[parser](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#parseroptionsproject).

## 🗑 Ignoring files and folders

You can ignore files and folders by either providing specific files/globs of the files you want linted
to `ts-standard` when running the command or you can add an `ignore` property to your `package.json`
`ts-standard` configuration settings.
You can add an `ignore` property to your `package.json` `ts-standard` configuration settings.

```json
{
Expand All @@ -95,28 +94,6 @@ to `ts-standard` when running the command or you can add an `ignore` property to
}
```

## 🎛 Package.json Options

```jsonc
{
"ts-standard": {
"ignore": [""], // files/folders/globs to ignore
"noDefaultIgnore": false, // disable ignoring default locations (e.g. node_modules, .git, etc...)
"globals": [""], // global variables to define (e.g. $, jquery, etc...)
"plugins": [""], // Extra eslint plugins to use
"envs": [""], // eslint environments to use (e.g. node, browser, etc...)
"parser": "", // a different eslint parser to use (e.g. babel, etc...)
"cwd": "", // the root working directory where the project file is located
"eslint": "", // path to a custom eslint linter
"files": [""], // files/folders/globs to include in the linting
"project": [""], // relative path to `tsconfig.json` file
"fix": false, // auto fix any lint errors found that are fixable
"report": "", // an eslint formatter to output the lint results as (e.g. standard, stylish, json, etc...)
"extensions": "", // a list of file extensions to lint by default (e.g. js,jsx,ts,tsx,mjs,cjs)
}
}
```

## 🚫 Please change X rule

This project has no control over the rules implemented, as such this project cannot change any of the
Expand Down Expand Up @@ -147,6 +124,5 @@ creating a typescript specific standard.
I welcome all pull requests. Please make sure you add appropriate test cases for any features
added. Before opening a PR please make sure to run the following scripts:

- `npm run lint` checks for code errors and format according to [ts-standard](https://github.com/standard/ts-standard)
- `npm run lint:standard` checks for code errors and format according to [standard](https://github.com/standard/standard)
- `npm test` make sure all tests pass
- `npm run coverage` make sure the coverage has not decreased from current master
3 changes: 0 additions & 3 deletions bin/cmd.js

This file was deleted.

67 changes: 67 additions & 0 deletions cli.js
@@ -0,0 +1,67 @@
#!/usr/bin/env node

import { cli } from 'standard-engine'
import minimist from 'minimist'

import options from './options.js'
import { CURRENT_WORKING_DIRECTORY } from './constants.js'
import { _getTSConfigPath } from './resolve-tsconfig.js'

const tsStandardCli = () => {
const cliOptions = { ...options }

const argv = minimist(process.argv.slice(2), {
alias: {
project: 'p',
help: 'h'
},
boolean: ['help'],
string: ['project']
})

if (argv.help) {
console.log(
'%s - %s (%s)',
cliOptions.cmd,
cliOptions.tagline,
cliOptions.homepage
)
console.log(`
Usage:
${cliOptions.cmd} <flags> [FILES...]
If FILES is omitted, all JavaScript/TypeScript source files (*.js, *.jsx, *.mjs, *.cjs, *.ts, *.tsx)
in the current working directory are checked, recursively.
Certain paths (node_modules/, coverage/, vendor/, *.min.js, and
files/folders that begin with '.' like .git/) are automatically ignored.
Paths in a project's root .gitignore file are also automatically ignored.
Flags:
--fix Automatically fix problems
-p, --project Specify ts-config location (default: ./tsconfig.eslint.json or ./tsconfig.json)
--version Show current version
-h, --help Show usage information
Flags (advanced):
--stdin Read file text from stdin
--ext Specify JavaScript/TypeScript file extensions
--global Declare global variable
--plugin Use custom eslint plugin
--env Use custom eslint environment
--parser Use custom ts/js parser (default: @typescript-eslint/parser)
`)
process.exitCode = 0
return
}

cliOptions.eslintConfig.overrideConfig.parserOptions.project = _getTSConfigPath(
CURRENT_WORKING_DIRECTORY,
argv.project
)

cli(cliOptions)
}

tsStandardCli()
8 changes: 8 additions & 0 deletions constants.js
@@ -0,0 +1,8 @@
export const DEFAULT_TSCONFIG_LOCATIONS = [
'tsconfig.eslint.json',
'tsconfig.json'
]

export const DEFAULT_EXTENSIONS = ['js', 'jsx', 'mjs', 'cjs', 'ts', 'tsx']

export const CURRENT_WORKING_DIRECTORY = process.cwd()
25 changes: 0 additions & 25 deletions dist/cli.d.ts

This file was deleted.

0 comments on commit c3de7fe

Please sign in to comment.