From cbb79a4061372ae810887b900c9082cfe94d104f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Zl=C3=A1mal?= Date: Mon, 10 Jun 2019 10:04:48 -0500 Subject: [PATCH] Eslint config: add new rule 'flowtype/require-inexact-type' I had to wait a little bit because of this issue: https://github.com/gajus/eslint-plugin-flowtype/pull/408#issuecomment-500373495 (fixed here: https://github.com/gajus/eslint-plugin-flowtype/pull/409). Implicit inexact objects are now officially disabled in Universe. kiwicom-source-id: 9eda5b44be7928d6b4ff505b5e447b8c75dbda1b --- CHANGELOG.md | 3 +++ __tests__/__snapshots__/index.test.js.snap | 1 + __tests__/__snapshots__/nitroDifferences.test.js.snap | 1 + ourRules.js | 1 + package.json | 2 +- 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dddf322..1467886 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Unreleased +This release focuses on enabling more rules to match closer with Nitro config. It also shows new warnings for implicit inexact Flow types as a preparation for [exact objects by default](https://medium.com/flow-type/on-the-roadmap-exact-objects-by-default-16b72933c5cf). As always, please do not hesitate to upgrade, fix all your warnings and report any issues and misbehavior. + +- New rule for checking inexact Flow types (warnings or errors in strict mode): [`flowtype/require-inexact-type`](https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-require-inexact-type) - Following rules now show warnings (errors in strict mode): [`no-template-curly-in-string`](https://eslint.org/docs/rules/no-template-curly-in-string), [`array-callback-return`](https://eslint.org/docs/rules/array-callback-return), [`no-loop-func`](https://eslint.org/docs/rules/no-loop-func), [`vars-on-top`](https://eslint.org/docs/rules/vars-on-top), [`no-nested-ternary`](https://eslint.org/docs/rules/no-nested-ternary), [`prefer-template`](https://eslint.org/docs/rules/prefer-template) - Following React-related rules now show warnings (errors in strict mode): [`react/button-has-type`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/button-has-type.md), [`react/no-danger-with-children`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md), [`react/no-find-dom-node`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md), [`react/no-is-mounted`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md), [`react/no-multi-comp`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md), [`react/no-render-return-value`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md), [`react/jsx-uses-vars`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md), [`react/no-this-in-sfc`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-this-in-sfc.md), [`react/void-dom-elements-no-children`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md), [`react/prefer-es6-class`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md), [`react/no-unused-state`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-state.md), [`react/no-unescaped-entities`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md) diff --git a/__tests__/__snapshots__/index.test.js.snap b/__tests__/__snapshots__/index.test.js.snap index 1c8d90e..6f07028 100644 --- a/__tests__/__snapshots__/index.test.js.snap +++ b/__tests__/__snapshots__/index.test.js.snap @@ -119,6 +119,7 @@ Object { "flowtype/object-type-delimiter": "off", "flowtype/require-compound-type-alias": 0, "flowtype/require-exact-type": 0, + "flowtype/require-inexact-type": 1, "flowtype/require-parameter-type": 0, "flowtype/require-readonly-react-props": 0, "flowtype/require-return-type": 0, diff --git a/__tests__/__snapshots__/nitroDifferences.test.js.snap b/__tests__/__snapshots__/nitroDifferences.test.js.snap index e008c96..65072fd 100644 --- a/__tests__/__snapshots__/nitroDifferences.test.js.snap +++ b/__tests__/__snapshots__/nitroDifferences.test.js.snap @@ -359,6 +359,7 @@ N - flowtype/no-primitive-constructor-types ("warn") N - flowtype/no-unused-expressions ("error") N - flowtype/require-compound-type-alias ("off") N - flowtype/require-exact-type ("off") +N - flowtype/require-inexact-type ("error") N - flowtype/require-types-at-top ("off") N - flowtype/require-variable-type ("off") N - flowtype/sort-keys ("off") diff --git a/ourRules.js b/ourRules.js index 715ded5..1296685 100644 --- a/ourRules.js +++ b/ourRules.js @@ -264,6 +264,7 @@ module.exports = { 'flowtype/no-weak-types': OFF, 'flowtype/require-compound-type-alias': OFF, 'flowtype/require-exact-type': OFF, + 'flowtype/require-inexact-type': NEXT_VERSION_ERROR, 'flowtype/require-parameter-type': OFF, 'flowtype/require-readonly-react-props': OFF, // TODO: https://github.com/gajus/eslint-plugin-flowtype/pull/400#issuecomment-492828739 'flowtype/require-return-type': OFF, diff --git a/package.json b/package.json index 3598144..cde9fea 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "eslint-plugin-babel": "^5.3.0", "eslint-plugin-dependencies": "^2.4.0", "eslint-plugin-eslint-comments": "^3.1.1", - "eslint-plugin-flowtype": "^3.9.1", + "eslint-plugin-flowtype": "^3.10.1", "eslint-plugin-import": "^2.17.3", "eslint-plugin-jest": "^22.6.4", "eslint-plugin-jsx-a11y": "^6.2.1",