Skip to content

Commit

Permalink
feat: typescript support
Browse files Browse the repository at this point in the history
closes #31
  • Loading branch information
Rob McGuinness committed Jun 18, 2019
1 parent 18ad7d8 commit 1cb8741
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 37 deletions.
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# eslint-config-availity

> Shareable ESLint config for Availity projects designed to be used with [Prettier](https://github.com/prettier/prettier)
> Shareable ESLint config for Availity projects designed to be used with [Prettier](https://github.com/prettier/prettier) and Typescript[https://www.typescriptlang.org/]
[![](https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge)](http://opensource.org/licenses/MIT)
[![](http://img.shields.io/npm/v/eslint-config-availity.svg?style=for-the-badge&logo=npm)](https://npmjs.org/package/eslint-config-availity)
Expand All @@ -13,13 +13,15 @@ npm install eslint-config-availity --save-dev
```

## Features
- [eslint-config-airbnb-base](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base)
- [eslint-config-airbnb](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb)
- [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier)
- [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest)
- [eslint-plugin-promise](https://github.com/xjamundx/eslint-plugin-promise)
- [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn)
- [eslint-plugin-react-hooks](https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks)

- [eslint-config-airbnb-base](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base)
- [eslint-config-airbnb](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb)
- [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier)
- [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest)
- [eslint-plugin-promise](https://github.com/xjamundx/eslint-plugin-promise)
- [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn)
- [eslint-plugin-react-hooks](https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks)
- [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin)

## Usage

Expand All @@ -41,7 +43,7 @@ extends: availity/browser

> Recommended settings
```
```js
{
"printWidth": 120,
"singleQuote": true,
Expand All @@ -51,12 +53,12 @@ extends: availity/browser

## Contributing

* `npm install`
* Make necessary changes
* Update `README.md` and `test.js` if necessary
* Run `npm run release`. This command parses `angular` style commits using `conventional-changelog` to determine the next version for the packages
* Alternatively, run `npm run release ${VERSION}` and the release script will use `${VERSION}` as the version number in `package.json`
* Run `npm pulish` or `npm publish --tag=next` (if working on next release candidate)
- `npm install`
- Make necessary changes
- Update `README.md` and `test.js` if necessary
- Run `npm run release`. This command parses `angular` style commits using `conventional-changelog` to determine the next version for the packages
- Alternatively, run `npm run release ${VERSION}` and the release script will use `${VERSION}` as the version number in `package.json`
- Run `npm pulish` or `npm publish --tag=next` (if working on next release candidate)

## Disclaimer

Expand Down
22 changes: 22 additions & 0 deletions base.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
const typescriptRules = require('@typescript-eslint/eslint-plugin/dist/configs/recommended.json');

module.exports = {
root: true,

parser: 'babel-eslint',

extends: [
Expand All @@ -17,8 +21,26 @@ module.exports = {

env: {
jest: true,
node: true,
},

overrides: [
{
files: ['**/*.ts', '**/*.tsx'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
// typescript-eslint specific options
warnOnUnsupportedTypeScriptVersion: true,
},
plugins: ['@typescript-eslint'],
rules: Object.assign(typescriptRules, {
'@typescript-eslint/no-unused-vars': 'off',
}),
},
],

rules: {
strict: 0,
'no-var': 2,
Expand Down
23 changes: 22 additions & 1 deletion browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ module.exports = {
env: {
browser: true,
jest: true,
es6: true,
node: false,
},

plugins: ['promise', 'jest', 'promise', 'unicorn', 'react-hooks'],

parserOptions: {
sourceType: 'module',
ecmaFeatures: { legacyDecorators: true }, // This goes away with babel-eslint@11 https://github.com/babel/babel-eslint/issues/662#issuecomment-459712913
ecmaVersion: 2018,
ecmaFeatures: {
legacyDecorators: true, // This goes away with babel-eslint@11 https://github.com/babel/babel-eslint/issues/662#issuecomment-459712913
jsx: true,
},
},

globals: {
Expand All @@ -33,6 +39,21 @@ module.exports = {
__STAGING__: true,
},

overrides: [
{
files: ['**/*.ts', '**/*.tsx'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
// typescript-eslint specific options
warnOnUnsupportedTypeScriptVersion: true,
},
plugins: ['@typescript-eslint'],
rules: base.overrides[0].rules,
},
],

rules: Object.assign({}, base.rules, {
'react/sort-comp': 0,
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
Expand Down

0 comments on commit 1cb8741

Please sign in to comment.