Skip to content

Commit

Permalink
Merge pull request #10 from derniercri/feature/typescript-support
Browse files Browse the repository at this point in the history
Support for TypeScript
  • Loading branch information
Jean-Serge authored Jul 25, 2019
2 parents faa0582 + de5fa95 commit f05332b
Show file tree
Hide file tree
Showing 9 changed files with 1,594 additions and 652 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ And a `.prettierrc` (`prettier` can't read `eslint` configuration) :
}
```

And voilà !
Finally the following script to your `package.json`

```json
"lint": "eslint 'src/**/*.{t,j}s{,x}'"
```

And voilà !

Check the **sample** folder of this repository for a concrete example.
146 changes: 11 additions & 135 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,138 +1,14 @@
module.exports = {
extends: ['airbnb', 'prettier', 'prettier/react'],

env: {
node: true,
browser: true,
},

parser: '@typescript-eslint/parser',
extends: [
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:react/recommended',
'plugin:prettier/recommended'
],
rules: {
printWidth: 100,
semi: 0,
singleQuote: true,
trailingComma: 'all',
'arrow-body-style': [2, 'as-needed'],
'arrow-parens': 0,
'class-methods-use-this': 0,
'comma-dangle': [2, 'always-multiline'],
'consistent-return': 0,
'default-case': 0,
'dot-notation': 0,
'func-names': 0,
'global-require': 0,
'key-spacing': [2, { mode: 'strict' }],
'max-len': 0,
'new-cap': 0,
'newline-after-var': [2, 'always'],
'no-case-declarations': 0,
'no-confusing-arrow': 0,
'no-console': 2,
'no-extra-boolean-cast': 0,
'no-lonely-if': 0,
'no-mixed-operators': 0,
'no-multi-spaces': 2,
'no-nested-ternary': 0,
'no-param-reassign': 2,
'no-plusplus': 0,
'no-prototype-builtins': 0,
'no-restricted-syntax': 0,
'no-return-assign': 0,
'no-shadow': 2,
'no-throw-literal': 0,
'no-underscore-dangle': 0,
'no-unused-expressions': 0,
'no-unused-vars': [2, { varsIgnorePattern: '^debug$' }],
'no-use-before-define': 0,
'no-useless-escape': 0,
'no-void': 0,
'object-curly-spacing': [2, 'always'],
'object-shorthand': 0,
'one-var': 0,
'operator-assignment': 0,
'padded-blocks': [0, { classes: 'always', switches: 'never' }],
'quote-props': [2, 'as-needed'],
'space-before-function-paren': [2, {
'anonymous': 'never',
'named': 'never',
'asyncArrow': 'always',
}],
'space-in-parens': [2, 'never'],
'vars-on-top': 0,
camelcase: 0,
eqeqeq: 0,
indent: [2, 2, { SwitchCase: 1 }],
quotes: [2, 'single'],
radix: 0,
strict: 0,

'import/no-unresolved': 0,
'import/extensions': 0,
'import/first': 0,
'import/no-dynamic-require': 0,
'import/no-extraneous-dependencies': 0,
'import/prefer-default-export': 0,

'jsx-a11y/anchor-is-valid': 0,
'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/href-no-hash': 0,
'jsx-a11y/iframe-has-title': 0,
'jsx-a11y/label-has-for': 0,
'jsx-a11y/mouse-events-have-key-events': 0,
'jsx-a11y/no-autofocus': 0,
'jsx-a11y/no-noninteractive-element-interactions': 0,
'jsx-a11y/no-noninteractive-tabindex': 0,
'jsx-a11y/no-static-element-interactions': 0,

'react/forbid-prop-types': 0,
'react/jsx-boolean-value': [2, 'never'],
'react/jsx-closing-bracket-location': 0,
'react/jsx-curly-spacing': [2, 'never', { allowMultiline: false }],
'react/jsx-filename-extension': 0,
'react/jsx-indent-props': [2, 2],
'react/jsx-key': 2,
'react/jsx-no-bind': 0,
'react/jsx-no-duplicate-props': 2,
'react/jsx-no-target-blank': 0,
'react/jsx-pascal-case': 2,
'react/jsx-uses-react': 2,
'react/no-danger': 0,
'react/no-did-mount-set-state': 0,
'react/no-did-update-set-state': 0,
'react/no-multi-comp': 0,
'react/no-unused-prop-types': 1,
'react/prefer-es6-class': 2,
'react/prefer-stateless-function': 0,
'react/prop-types': 0,
'react/require-default-props': 0,

'react/sort-comp': [
2,
{
order: [
'static-methods',
'/^_.+$/',
'state',
'constructor',
'lifecycle',
'/^(on|handle).+$/',
'/^(get|set).+$/',
'/^is.+$/',
'everything-else',
'/^render.+$/',
'render',
],
groups: {
lifecycle: [
'componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'componentDidUpdate',
'componentWillUnmount',
],
},
},
],
},
'jsx-boolean-value': 0,
'jsx-no-lambda': 0,
'newline-before-return': 1
}
}
24 changes: 16 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
{
"name": "eslint-config-derniercri",
"version": "1.0.0",
"version": "3.0.0",
"description": "Dernier Cri Eslint config",
"main": "index.js",
"repository": "[email protected]:derniercri/eslint-config.git",
"author": "Maxime Brazeilles <[email protected]>",
"contributors": [
"Jean-Serge Monbailly <[email protected]>"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/derniercri/eslint-config-derniercri/issues"
},
"homepage": "https://github.com/derniercri/eslint-config-derniercri",
"dependencies": {
"eslint": "^5.0.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^3.3.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"prettier": "^1.15.2"
"@typescript-eslint/eslint-plugin": "^1.11.0",
"@typescript-eslint/parser": "^1.11.0",
"eslint": "^6.0.1",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-react": "^7.14.2",
"prettier": "^1.18.2",
"typescript": "^3.3.3333"
},
"private": true
}
5 changes: 5 additions & 0 deletions sample/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"derniercri"
]
}
13 changes: 13 additions & 0 deletions sample/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// bad
function badNewlineBeforeReturn() {
const a = 2 + 3;

return a;
}

// good
function goodNewlineBeforeReturn() {
const a = 2 + 3;

return a;
}
12 changes: 12 additions & 0 deletions sample/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// bad
function badNewlineBeforeReturn() {
const a = 2 + 3
return a
}

// good
function goodNewlineBeforeReturn() {
const a = 2 + 3

return a
}
16 changes: 16 additions & 0 deletions sample/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "sample",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"lint": "eslint '*.{t,j}s{,x}'"
},
"author": "",
"license": "ISC",
"dependencies": {
"eslint": "^5.12.1",
"eslint-config-derniercri": "file:..",
"typescript": "^3.3.3333"
}
}
Loading

0 comments on commit f05332b

Please sign in to comment.