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

ESLint: Configuration for TypeScript #298

Merged
merged 6 commits into from
Apr 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
module.exports = {
'parser': 'babel-eslint',
'parser': '@typescript-eslint/parser',
'extends': [
'airbnb',
'plugin:prettier/recommended',
'prettier/react',
],
'plugins': [
'@typescript-eslint',
],
'parserOptions': {
'sourceType': 'module',
'project': './tsconfig.json',
},
'env': {
'browser': true
},
'rules': {
'no-nested-ternary': 0,
'react/no-multi-comp': 0,
'react/jsx-no-bind': 0,
'react/jsx-filename-extension': [1, { 'extensions': ['.js', '.jsx'] }],
'react/jsx-filename-extension': [1, { 'extensions': ['.js', '.jsx', '.ts', '.tsx'] }],
'jsx-a11y/no-static-element-interactions': 0,
'class-methods-use-this': 0,
'react/no-unused-prop-types': 1,
Expand All @@ -37,6 +44,7 @@ module.exports = {
}
],
'no-return-assign': [2, 'except-parens'],
'import/no-cycle': 0,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This occurs in Picklist and DropdownMenu.


// TODO: Fix or disable
'react/require-default-props': 1,
Expand All @@ -50,5 +58,15 @@ module.exports = {
'jsx-a11y/anchor-is-valid': 1,
'jsx-a11y/interactive-supports-focus': 2,
'jsx-a11y/label-has-associated-control': [2, { assert: 'either' }],

// For TypeScript
'camelcase': 0,
'@typescript-eslint/camelcase': 2,
'no-array-constructor': 0,
'@typescript-eslint/no-array-constructor': 2,
'no-unused-vars': 0,
'@typescript-eslint/no-unused-vars': 2,

'@typescript-eslint/no-unnecessary-type-assertion': 2,
}
};
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"type-check:watch": "npm run type-check -- --watch",
"format": "npm run lint:src -- --fix && npm run lint:stories -- --fix && npm run lint:test -- --fix",
"lint": "npm run lint:src && npm run lint:stories && npm run lint:test",
"lint:src": "eslint --ext .js src/scripts/**",
"lint:stories": "eslint --ext .js stories/**",
"lint:test": "eslint --ext .js test/**",
"lint:src": "eslint --ext .js,.jsx,.ts,.tsx src/scripts/**",
"lint:stories": "eslint --ext .js,.jsx,.ts,.tsx stories/**",
"lint:test": "eslint --ext .js,.jsx,.ts,.tsx test/**",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be summarized as one single lint script:

"lint": "eslint --ext .js,.jsx,.ts,.tsx src test stories"

But I left it as it is.

"build": "babel -d lib/ src/ --extensions \".js,.ts,.tsx\"",
"build:assets": "cp -r node_modules/@salesforce-ux/design-system/assets public",
"build:storybook": "build-storybook -o public",
Expand Down Expand Up @@ -69,6 +69,7 @@
"@storybook/addon-knobs": "5.0.5",
"@storybook/addon-storyshots": "^5.0.5",
"@storybook/react": "5.0.5",
"@typescript-eslint/eslint-plugin": "^1.5.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.4.2",
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/Lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ export default class Lookup extends Component {
className
);
const formElemProps = { id, totalCols, cols, label, required, error };
/* eslint-disable no-unused-vars */
/* eslint-disable no-unused-vars, @typescript-eslint/no-unused-vars */
const {
defaultSelected,
defaultOpened,
Expand All @@ -728,7 +728,7 @@ export default class Lookup extends Component {
onLookupRequest,
...searchProps
} = props;
/* eslint-enable no-unused-vars */
/* eslint-enable no-unused-vars, @typescript-eslint/no-unused-vars */
return (
<FormElement
formElementRef={(node) => (this.node = node)}
Expand Down
51 changes: 50 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,33 @@
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-12.0.10.tgz#17a8ec65cd8e88f51b418ceb271af18d3137df67"
integrity sha512-WsVzTPshvCSbHThUduGGxbmnwcpkgSctHGHTqzWyFg4lYAuV5qXlyFPOsP3OWqCINfmg/8VXP+zJaa4OxEsBQQ==

"@typescript-eslint/eslint-plugin@^1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.5.0.tgz#85c509bcfc2eb35f37958fa677379c80b7a8f66f"
integrity sha512-TZ5HRDFz6CswqBUviPX8EfS+iOoGbclYroZKT3GWGYiGScX0qo6QjHc5uuM7JN920voP2zgCkHgF5SDEVlCtjQ==
dependencies:
"@typescript-eslint/parser" "1.5.0"
"@typescript-eslint/typescript-estree" "1.5.0"
requireindex "^1.2.0"
tsutils "^3.7.0"

"@typescript-eslint/[email protected]":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-1.5.0.tgz#a96114d195dff2a49534e4c4850fb676f905a072"
integrity sha512-pRWTnJrnxuT0ragdY26hZL+bxqDd4liMlftpH2CBlMPryOIOb1J+MdZuw6R4tIu6bWVdwbHKPTs+Q34LuGvfGw==
dependencies:
"@typescript-eslint/typescript-estree" "1.5.0"
eslint-scope "^4.0.0"
eslint-visitor-keys "^1.0.0"

"@typescript-eslint/[email protected]":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.5.0.tgz#986b356ecdf5a0c3bc9889d221802149cf5dbd4e"
integrity sha512-XqR14d4BcYgxcrpxIwcee7UEjncl9emKc/MgkeUfIk2u85KlsGYyaxC7Zxjmb17JtWERk/NaO+KnBsqgpIXzwA==
dependencies:
lodash.unescape "4.0.1"
semver "5.5.0"

"@webassemblyjs/[email protected]":
version "1.8.5"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.8.5.tgz#51b1c5fe6576a34953bf4b253df9f0d490d9e359"
Expand Down Expand Up @@ -7222,6 +7249,11 @@ lodash.throttle@^4.1.1:
resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ=

[email protected]:
version "4.0.1"
resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c"
integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=

lodash@>4.17.4, lodash@^4.0.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.4:
version "4.17.11"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
Expand Down Expand Up @@ -9667,6 +9699,11 @@ require-main-filename@^1.0.1:
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"
integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=

requireindex@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.2.0.tgz#3463cdb22ee151902635aa6c9535d4de9c2ef1ef"
integrity sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==

requires-port@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
Expand Down Expand Up @@ -9860,6 +9897,11 @@ select@^1.1.2:
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b"
integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==

[email protected]:
version "5.5.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
integrity sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==

[email protected]:
version "0.16.2"
resolved "https://registry.yarnpkg.com/send/-/send-0.16.2.tgz#6ecca1e0f8c156d141597559848df64730a6bbc1"
Expand Down Expand Up @@ -10749,11 +10791,18 @@ trough@^1.0.0:
resolved "https://registry.yarnpkg.com/trough/-/trough-1.0.3.tgz#e29bd1614c6458d44869fc28b255ab7857ef7c24"
integrity sha512-fwkLWH+DimvA4YCy+/nvJd61nWQQ2liO/nF/RjkTpiOGi+zxZzVkhb1mvbHIIW4b/8nDsYI8uTmAlc0nNkRMOw==

tslib@^1.9.0:
tslib@^1.8.1, tslib@^1.9.0:
version "1.9.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==

tsutils@^3.7.0:
version "3.9.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.9.1.tgz#2a40dc742943c71eca6d5c1994fcf999956be387"
integrity sha512-hrxVtLtPqQr//p8/msPT1X1UYXUjizqSit5d9AQ5k38TcV38NyecL5xODNxa73cLe/5sdiJ+w1FqzDhRBA/anA==
dependencies:
tslib "^1.8.1"

[email protected]:
version "0.0.0"
resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"
Expand Down