Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/merge #27

Merged
merged 23 commits into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ad33780
add support for multiple tsconfigs
teoxoy Aug 3, 2019
7c85bfa
support glob patterns
teoxoy Aug 3, 2019
6954be1
add test for multiple tsconfigs
teoxoy Aug 3, 2019
52159fa
fix json syntax highlighting
teoxoy Aug 3, 2019
af7cfad
update docs to include info about multiple configs
teoxoy Aug 3, 2019
0fa2628
chore: rename package and publish to npm
JounQin Sep 10, 2019
6e54fc8
Merge remote-tracking branch 'upstream2/master' into support-multiple…
teoxoy Sep 10, 2019
9121f0b
[FEAT] Support multiple tsconfigs (#9)
JounQin Sep 10, 2019
7d89fd3
docs: update README, upgrade dependencies and release v0.2.0
JounQin Sep 10, 2019
8ac122e
refactor: change code base to TypeScript, better workflow
JounQin Sep 11, 2019
5d77453
chore: add missing codechecks configuration file
JounQin Sep 11, 2019
f937947
chore(release): bump version, improve README
JounQin Sep 11, 2019
8db18f7
chore(release): 0.3.0
JounQin Sep 11, 2019
bbe6d5d
chore(test): add back unexpectedly removed test cases
JounQin Sep 11, 2019
33696a8
chore: stricter lint rules for tests
JounQin Sep 12, 2019
f20d56c
ci: try to fix test error on CI due to glob
JounQin Sep 13, 2019
4f42ece
chore: remove travis related content
JounQin Sep 13, 2019
702f390
chore(deps): upgrade configurations
JounQin Sep 17, 2019
5eb4874
fix(deps): bump configurations, use resolutions to simplify tests
JounQin Sep 22, 2019
f436627
feat: replace glob with tiny-glob for faster speed, close #12
JounQin Sep 22, 2019
5f87698
feat: replace glob with tiny-glob for faster speed, close #12 (#13)
JounQin Sep 22, 2019
d81f8ee
chore(release): 0.4.0
JounQin Sep 22, 2019
970b2ef
Merge remote-tracking branch 'upstream/master' into chore/merge
JounQin Sep 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .commitlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"@1stg"
]
}
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
indent_style = space
indent_size = 2
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib
CHANGELOG.md
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { js } = require('@1stg/eslint-config/overrides')

module.exports = {
extends: ['@1stg', 'plugin:import/typescript', 'plugin:mdx/recommended'],
overrides: [js],
rules: {
'node/no-unsupported-features/es-syntax': 0,
},
}
68 changes: 68 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Node CI

on: [push, pull_request]

jobs:
build:
strategy:
matrix:
node: [8.x, 10.x, 12.x]
os: [macOS-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: setup yarn
run: |
curl -o- -L https://yarnpkg.com/install.sh | bash
export PATH="$HOME/.yarn/bin:$PATH"
- name: build, lint, test
run: |
yarn --frozen-lockfile
yarn build
yarn lint
yarn eslint -f friendly tests/**/*.{ts,tsx}
env:
CI: true
EFF_NO_LINK_RULES: true

# codecov:
# runs-on: macOS-latest
# needs: build
# steps:
# - name: Report Test Code Coverage
# if: matrix.node == '12.x'
# run: |
# yarn global add codecov codacy-coverage
# codecov
# cat ./coverage/lcov.info | codacy-coverage
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

deploy:
runs-on: macOS-latest
needs: build
steps:
- name: Publish Release and npm Package
if: github.event_name == 'push' && github.ref == 'master' && matrix.node == '12.x'
run: bash deploy.sh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_BRANCH: ${{ github.ref }}
GH_REPO: ${{ github.repository }}

codecheck:
runs-on: macOS-latest
needs: [build, deploy]
steps:
- name: Code Check
if: matrix.node == '12.x'
run: |
yarn add -D @codechecks/client @codechecks/build-size-watcher
yarn codechecks
env:
CC_SECRET: ${{ secrets.CC_SECRET }}
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.type-coverage
lib
node_modules
yarn-error.log
yarn.lock
.idea
.vscode
*.log
1 change: 1 addition & 0 deletions .huskyrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@1stg/husky-config')
1 change: 1 addition & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@1stg/lint-staged')
4 changes: 0 additions & 4 deletions .npmignore

This file was deleted.

1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@1stg/prettier-config"
5 changes: 5 additions & 0 deletions .remarkrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": [
"@1stg/remark-config"
]
}
3 changes: 3 additions & 0 deletions .renovaterc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@1stg"
}
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [0.4.0](https://github.com/rx-ts/eslint-import-resolver-ts/compare/v0.3.0...v0.4.0) (2019-09-22)

### Bug Fixes

- **deps:** bump configurations, use resolutions to simplify tests ([5eb4874](https://github.com/rx-ts/eslint-import-resolver-ts/commit/5eb4874))

### Features

- replace glob with tiny-glob for faster speed, close [#12](https://github.com/rx-ts/eslint-import-resolver-ts/issues/12) ([f436627](https://github.com/rx-ts/eslint-import-resolver-ts/commit/f436627))
- replace glob with tiny-glob for faster speed, close [#12](https://github.com/rx-ts/eslint-import-resolver-ts/issues/12) ([#13](https://github.com/rx-ts/eslint-import-resolver-ts/issues/13)) ([5f87698](https://github.com/rx-ts/eslint-import-resolver-ts/commit/5f87698))

## [0.3.0](https://github.com/rx-ts/eslint-import-resolver-ts/compare/v0.2.0...v0.3.0) (2019-09-11)
70 changes: 60 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,49 @@
# eslint-import-resolver-typescript

[![Build Status](https://travis-ci.org/alexgorbatchev/eslint-import-resolver-typescript.svg?branch=master)](https://travis-ci.org/alexgorbatchev/eslint-import-resolver-typescript)
[![GitHub Actions](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/workflows/Node%20CI/badge.svg)](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/actions)
[![type-coverage](https://img.shields.io/badge/dynamic/json.svg?label=type-coverage&prefix=%E2%89%A5&suffix=%&query=$.typeCoverage.atLeast&uri=https%3A%2F%2Fraw.githubusercontent.com%2Falexgorbatchev%2Feslint-import-resolver-typescript%2Fmaster%2Fpackage.json)](https://github.com/plantain-00/type-coverage)
[![npm](https://img.shields.io/npm/v/eslint-import-resolver-typescript.svg)](https://www.npmjs.com/package/eslint-import-resolver-typescript)
[![GitHub Release](https://img.shields.io/github/release/alexgorbatchev/eslint-import-resolver-typescript)](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/releases)

This plugin adds typescript support to [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import).
[![David Peer](https://img.shields.io/david/peer/alexgorbatchev/eslint-import-resolver-typescript.svg)](https://david-dm.org/alexgorbatchev/eslint-import-resolver-typescript?type=peer)
[![David](https://img.shields.io/david/alexgorbatchev/eslint-import-resolver-typescript.svg)](https://david-dm.org/alexgorbatchev/eslint-import-resolver-typescript)
[![David Dev](https://img.shields.io/david/dev/alexgorbatchev/eslint-import-resolver-typescript.svg)](https://david-dm.org/alexgorbatchev/eslint-import-resolver-typescript?type=dev)

[![Conventional Commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![codechecks.io](https://raw.githubusercontent.com/codechecks/docs/master/images/badges/badge-default.svg?sanitize=true)](https://codechecks.io)

This plugin adds TypeScript support to [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import).

This means you can:

- `import`/`require` files with extension `.ts`/`.tsx`!
- Use [`paths`](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping) defined in `tsconfig.json`.
- Prefer resolve `@types/*` definitions over plain `.js`.
- Multiple tsconfigs support just like normal.

## TOC <!-- omit in toc -->

- [Installation](#installation)
- [Configuration](#configuration)
- [Contributing](#contributing)

## Installation

```bash
npm install --save-dev eslint-plugin-import @typescript-eslint/parser eslint-import-resolver-typescript
```sh
# npm
npm i -D eslint-plugin-import @typescript-eslint/parser eslint-import-resolver-typescript

# yarn
yarn add -D eslint-plugin-import @typescript-eslint/parser eslint-import-resolver-typescript
```

## Configuration

Add the following to your `.eslintrc` config:

```CJSON
```jsonc
{
"plugins": ["import"],
"rules": {
Expand All @@ -32,23 +56,49 @@ Add the following to your `.eslintrc` config:
},
"import/resolver": {
// use <root>/tsconfig.json
"typescript": {},
"typescript": {
"alwaysTryTypes": true // always try to resolve types under `<roo/>@types` directory even it doesn't contain any source code, like `@types/unist`
},

// use <root>/path/to/folder/tsconfig.json
"typescript": {
"directory": "./path/to/folder"
},

// Multiple tsconfigs (Useful for monorepos)

// use a glob pattern
"typescript": {
"directory": "./packages/*/tsconfig.json"
},

// use an array
"typescript": {
"directory": [
"./packages/module-a/tsconfig.json",
"./packages/module-b/tsconfig.json"
]
},

// use an array of glob patterns
"typescript": {
"directory": [
"./packages/*/tsconfig.json",
"./other-packages/*/tsconfig.json"
]
}
}
}
}
```


## Contributing

- Make sure your change is covered by a test import.
- Make sure that `npm test` passes without a failure.
- Make sure your code is formatted `npm format`.
- Make sure that `yarn test` passes without a failure.
- Make sure that `yarn lint` passes without conflicts.
- Make sure your code changes match our [type-coverage](https://github.com/plantain-00/type-coverage) settings: `yarn type-coverage`.

We have [GitHub Actions](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/actions) which will run the above commands on your PRs.

We have an [automatic travis build](https://travis-ci.org/alexgorbatchev/eslint-import-resolver-typescript) which will run the above on your PRs.
If either fails, we won't be able to merge your PR until it's fixed.
10 changes: 10 additions & 0 deletions codechecks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
checks:
- name: build-size-watcher
options:
files:
- path: 'lib/index.js'
- name: type-coverage-watcher
options:
atLeast: 100
ignoreCatch: true
strict: true
16 changes: 16 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

git remote set-url origin "https://user:$GH_TOKEN@github.com/$GH_REPO.git"
npm set //registry.npmjs.org/:_authToken "$NPM_TOKEN"

git fetch origin "$GH_BRANCH":"$GH_BRANCH"
git checkout "$GH_BRANCH"

PKG_VERSION=$(jq -r '.version' package.json)

git fetch origin v"$PKG_VERSION" || {
yarn global add standard-version
standard-version -a --release-as "$PKG_VERSION"
git push --follow-tags origin "$GH_BRANCH"
npm publish
}
2 changes: 1 addition & 1 deletion dummy.js/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = 'dummy';
module.exports = 'dummy'