Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
Merge pull request #302 from saneyuki/react-new-rule
Browse files Browse the repository at this point in the history
Update new rules introduced by recently package updates
  • Loading branch information
tetsuharuohzeki authored Jan 21, 2020
2 parents 8af0eea + 6134980 commit a60dada
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/eslintrc_import.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ const styleguide = {
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
'import/order': ['warn', {
'alphabetize': {
'caseInsensitive': false,
'order': 'asc',
},
'groups': [
Expand Down
6 changes: 6 additions & 0 deletions config/eslintrc_react.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ module.exports = {
'allowInPropTypes': false, // We doubt this option is really useful.
}],
'react/forbid-prop-types': 0,

// TODO(#298): This rule should be sort with project style.
'react/function-component-definition': 0,

'react/no-access-state-in-setstate': 1,
// The index of `Array<T>` is not suitable for `key` props.
// But this restriction does not prevent that the id for each items is just a sequence number of some list
// even if a item has an "unique" id. This rule cannot prevent it. meaningless.
'react/no-array-index-key': 0,
'react/no-adjacent-inline-elements': 0,
'react/no-children-prop': 2, // children should be nested between the opening and closing tags.
'react/no-danger': 2,
'react/no-danger-with-children': 2,
Expand Down Expand Up @@ -180,6 +185,7 @@ module.exports = {
'react/jsx-no-comment-textnodes': 2,
'react/jsx-no-duplicate-props': 2,
'react/jsx-no-literals': 1,
'react/jsx-no-script-url': 2,
'react/jsx-no-target-blank': [1, { // see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
'enforceDynamicLinks': 'always',
// For legacy browsers which does not support `rel=noopener`, this option is useful.
Expand Down
23 changes: 23 additions & 0 deletions config/eslintrc_typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ module.exports = {
// Each style has its own pros & cons.
'@typescript-eslint/consistent-type-definitions': 'off',

// This avoid misusing functions
'@typescript-eslint/default-param-last': 'error',

// TODO: (#64) @typescript-eslint/explicit-function-return-type

// It's redundant to enforce to supply `public`.
Expand All @@ -71,6 +74,8 @@ module.exports = {
},
}],

// TODO: #301
'@typescript-eslint/explicit-module-boundary-types': 'off',

// * We accept the style for T , TA , TAbc , TA1Bca , T1 , T2.
// * You seem this style is similar to C# or typescript compiler.
Expand Down Expand Up @@ -137,6 +142,8 @@ module.exports = {
],
}],

// TODO(#300): '@typescript-eslint/naming-convention'

// This should be sorted with ESLint builtin rule.
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'error',
Expand Down Expand Up @@ -177,6 +184,10 @@ module.exports = {
'no-extra-parens': 'off',
'@typescript-eslint/no-extra-parens': 'off',

// This should be sorted with ESLint builtin rule.
'no-extra-semi': 'off',
'@typescript-eslint/no-extra-semi': 'warn',

// Of course, this might be redundant if you set unhandledrejection event handler.
// We still have some points which should be under discussion. See: #135
'@typescript-eslint/no-floating-promises': ['warn', {
Expand All @@ -187,6 +198,10 @@ module.exports = {
// This is common pitfalls for beginners. We must ban.
'@typescript-eslint/no-for-in-array': 'error',

// Basically, we should ban this kind of idioms.
// However, if you need to use `new Function`, then you can opt-out this rule.
'@typescript-eslint/no-implied-eval': 'error',

// Type inference is useful feature for Gradual Typing and other static typing system.
// However, over omission would increases compile (type checking) time and
// lacks the aspect of type annotation benefits as _documentation_.
Expand Down Expand Up @@ -221,6 +236,9 @@ module.exports = {
'allowDefinitionFiles': true,
}],

// Ban this pattern to keep type safety
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',

// Please opt-out this rule if you don't have any workarounds.
'@typescript-eslint/no-non-null-assertion': 'warn',

Expand All @@ -242,13 +260,18 @@ module.exports = {
'allowedNames': ['self'],
}],

// Should throw only Error or derived classes.
'@typescript-eslint/no-throw-literal': 'error',

// Disabling this does not make sense completely.
'@typescript-eslint/no-type-alias': 'off',

// This would find the possibility which we can unnecessary condition.
'@typescript-eslint/no-unnecessary-condition': ['warn', {
'ignoreRhs': false,
'allowConstantLoopConditions': true,
// FIXME: #299
'checkArrayPredicates': false,
}],

// Try to detect redundant case,
Expand Down

0 comments on commit a60dada

Please sign in to comment.