Skip to content

Commit

Permalink
feat: add typescript support
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Mollweide committed Apr 15, 2019
1 parent 6461b3d commit f6a9b0d
Show file tree
Hide file tree
Showing 64 changed files with 3,180 additions and 442 deletions.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

[![Build Status](https://img.shields.io/travis/namics/eslint-config-namics/master.svg)](https://travis-ci.org/namics/eslint-config-namics)
[![Build Status](https://ci.appveyor.com/api/projects/status/sroqr91h6gjecoqi/branch/master?svg=true)](https://ci.appveyor.com/project/smollweide/eslint-config-namics/branch/master)
[![Dependencies](https://img.shields.io/david/namics/eslint-config-namics/master.svg)](https://david-dm.org/namics/eslint-config-namics)
[![npm](https://img.shields.io/npm/v/@namics/eslint-config.svg)](https://www.npmjs.com/package/@namics/eslint-config)
[![Codestyle](https://img.shields.io/badge/codestyle-namics-green.svg)](https://github.com/namics/eslint-config-namics)

Expand All @@ -12,6 +11,35 @@
$ npm install --save-dev eslint eslint-plugin-import @namics/eslint-config
```

## Usage Typescript (recommended)

- `@namics/eslint-config/configurations/typescript-browser` - typescript + browser
- `@namics/eslint-config/configurations/typescript-react` - typescript + react
- `@namics/eslint-config/configurations/typescript-node` - typescript + node

*package.json*

```json
{
"scripts": {
"lint:ts": "eslint . --ext .jsx,.js,.ts,.tsx"
}
}
```

*Enabling ESLint on TS files in VSCode*

You need to update the eslint.validate setting to:

```json
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
]
```

## Usage ES8 (ES2017)

- `@namics/eslint-config/configurations/es8-browser` - ES8 + browser
Expand Down Expand Up @@ -84,6 +112,7 @@ then run `npm run lint`
- [Imports](./documentation/imports.md) (ES6/7/8)
- [React](./documentation/react.md) (ES6/7/8)
- [React A11y](./documentation/react-a11y.md) (ES6/7/8)
- [Typescript](./documentation/typescript.md) (typescript)

## Thanks to

Expand Down
5 changes: 5 additions & 0 deletions configurations/typescript-browser-disable-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
extends: [
'./typescript-disable-styles.js',
].map(require.resolve),
};
16 changes: 16 additions & 0 deletions configurations/typescript-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
extends: [
'./typescript.js',
].map(require.resolve),
env: {
browser: true,
node: false,
amd: false,
mocha: true,
jasmine: true,
jest: true,
jquery: true,
serviceworker: true,
worker: true,
},
};
14 changes: 14 additions & 0 deletions configurations/typescript-disable-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {

extends: [
'../rules/best-practices-disable-styles.js',
'../rules/errors-disable-styles.js',
'../rules/style-disable-styles.js',
'../rules/variables-disable-styles.js',
'../rules/imports-disable-styles.js',
'../rules/es6-disable-styles.js',
'../rules/es8-disable-styles.js',
'../rules/typescript-disable-styles.js',
].map(require.resolve),

};
7 changes: 7 additions & 0 deletions configurations/typescript-node-disable-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: [
'./typescript-disable-styles.js',
'../rules/node-disable-styles.js',
].map(require.resolve),
};

17 changes: 17 additions & 0 deletions configurations/typescript-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
extends: [
'./typescript.js',
'../rules/node.js',
].map(require.resolve),
env: {
browser: false,
node: true,
amd: false,
mocha: true,
jasmine: true,
jest: true,
jquery: true,
serviceworker: true,
worker: true,
},
};
7 changes: 7 additions & 0 deletions configurations/typescript-react-disable-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
'extends': [
'./typescript-disable-styles.js',
'../rules/react-disable-styles.js',
'../rules/react-a11y-disable-styles.js',
].map(require.resolve),
};
38 changes: 38 additions & 0 deletions configurations/typescript-react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
'plugins': [
'@typescript-eslint',
'jsx-a11y',
'react',
],
'extends': [
'./typescript.js',
'../rules/react.js',
'../rules/react-a11y.js',
].map(require.resolve),
'env': {
'browser': true,
'node': false,
'amd': false,
'mocha': true,
'jasmine': true,
'jest': true,
'jquery': true,
'serviceworker': true,
'worker': true,
},
'parserOptions': {
'ecmaVersion': 8,
'sourceType': 'module',
'ecmaFeatures': {
'jsx': true,
},
},
'settings': {
'import/resolver': {
'node': {
'extensions': ['.js', '.ts', '.jsx', '.tsx', '.json'],
},
},
},

};
25 changes: 25 additions & 0 deletions configurations/typescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {

parser: '@typescript-eslint/parser',

plugins: [
'@typescript-eslint',
],

extends: [
'../rules/node-disable.js',
'../rules/best-practices.js',
'../rules/errors.js',
'../rules/style.js',
'../rules/variables.js',
'../rules/imports.js',
'../rules/es6.js',
'../rules/es8.js',
'../rules/typescript.js',
].map(require.resolve),

parserOptions: {
project: './tsconfig.json',
},

};
12 changes: 12 additions & 0 deletions documentation/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,18 @@ var sum = 1 + 2;

:white_check_mark: Enabled (error)

```javascript

// Bad
/*
//comment
///<reference path="../../../../node_modules/@types/react/index.d.ts" />
*/
// Good
// comment
/// <reference path="../../../../node_modules/@types/react/index.d.ts" />

```
<br />


Expand Down
Loading

0 comments on commit f6a9b0d

Please sign in to comment.