create react app and flow TypeError: Cannot read property 'type' of undefined
Is this a bug report?
no
Did you try recovering your dependencies?
Yes I tried, but it doesn't help
Environment
Environment: OS: Windows 10 Node: 10.5.0 Yarn: Not Found npm: 6.1.0 Watchman: Not Found Xcode: N/A Android Studio: Not Found
Packages: (wanted => installed) react: ^16.4.1 => 16.4.1 react-dom: ^16.4.1 => 16.4.1 react-scripts: 1.1.4 => 1.1.4
Steps to Reproduce
(Write your steps here:)
- created create-react-app
- installed flow as in create-react-app documentation
- created a function which has parameters with Type alias,
When I defined ChainingType, eslint shows me an error.
type ChainingType = {
partName: string,
apiName: string
};
export const getChainingUrl = (props: ChainingType, param: string) => {
const baseUrlV1 = getBackendUrl('v1');
const { partName, apiName } = props;
switch (apiName) {
case API_NAME.userInfo:
return { /*some code */ };
case API_NAME.otherInfo:
return { /*some code */ };
default:
console.error('getChainingUrl error: define proper url for api =', apiName);
return 'undefined_url';
}
};
Expected Behavior
File lints with no troubles
(Write what you thought would happen.)
Actual Behavior
Eslint shows a Type Error for type ChainingType, linting error
Eslint shows me an TypeError

in console

My package json
{
"name": "blablablaber",
"version": "1.0.0",
"private": true,
"homepage": "/blablablaber/",
"dependencies": {
"babel-polyfill": "^6.26.0",
"bootstrap": "^4.1.1",
"classnames": "^2.2.6",
"flow-bin": "^0.79.1",
"history": "^4.7.2",
"isomorphic-fetch": "^2.2.1",
"moment": "^2.22.2",
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react-datepicker": "^1.5.0",
"react-dom": "^16.4.1",
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"react-router-redux": "^5.0.0-alpha.9",
"react-scripts": "1.1.4",
"react-select": "^1.2.1",
"reactstrap": "^6.1.0",
"redux": "^4.0.0",
"redux-devtools-extension": "^2.13.5",
"redux-form": "^7.4.2",
"redux-saga": "^0.16.0",
"reselect": "^3.0.1",
"styled-components": "^3.3.3",
"superagent": "^3.8.3"
},
"devDependencies": {
"eslint": "^5.1.0",
"eslint-config-standard": "^11.0.0",
"eslint-config-standard-react": "^6.0.0",
"eslint-loader": "^2.0.0",
"eslint-plugin-flowtype": "^2.50.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jest": "^21.17.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-standard": "^3.1.0"
},
"scripts": {
"lint": "eslint **/*.jsx --ignore-pattern node_modules/",
"flow": "flow",
"coverage": "npm test -- --coverage",
"test": "react-scripts test --env=jsdom --coverage",
"start": "react-scripts start",
"build": "react-scripts build",
"mockserver": "node mock/expressMockServer.js"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx}",
"!<rootDir>/node_modules/",
"!<rootDir>/path/to/dir/",
"!src/registerServiceWorker.js",
"!**/constants.js",
"!**/constants/*",
"!**/initialState.js",
"!**/__test__/*"
],
"coverageThreshold": {
"global": {
"branches": 40,
"functions": 40,
"lines": 40,
"statements": 40
}
},
"coverageReporters": [
"lcov",
"clover",
"cobertura"
]
}
}
my eslintrc:
{
"extends": [
"standard",
"standard-react",
"plugin:react/recommended",
"plugin:jest/recommended",
"plugin:flowtype/recommended"
],
"plugins": [
"react",
"jest",
"flowtype"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2017,
"ecmaFeatures": {
"jsx": true
}
},
"settings": {
"react": {
"pragma": "React",
"version": "16.0"
}
},
"env": {
"browser": true,
"jquery": true,
"es6": true
},
"rules": {
"eqeqeq": "warn",
"no-unused-vars": "warn",
"semi": ["error", "always"],
"space-before-function-paren": ["error", "never"],
"camelcase": [1, {"properties": "never"}],
"comma-dangle": "off",
"no-bitwise": [
"error",
{
"allow": [
"~"
]
}
],
"quote-props": [
"error",
"as-needed",
{
"keywords": true
}
],
"quotes": [
"error",
"single",
{
"avoidEscape": true
}
],
"no-undefined": 0,
"no-plusplus": [
"error",
{
"allowForLoopAfterthoughts": true
}
],
"object-curly-newline": 0,
"no-ternary": 0,
"no-underscore-dangle": 0,
"linebreak-style": 0,
"operator-linebreak": ["warn", "after"],
"padded-blocks": 0,
"object-shorthand": 0,
"no-var": [
"error"
],
"sort-vars": 0,
"id-length": [
"off",
{
"exceptions": [
"$",
"_",
"i",
"j"
]
}
],
"max-len": [
"warn",
160,
4
],
"max-params": 0,
"max-statements": [
"error",
20
],
"multiline-ternary": "off",
"newline-before-return": "off",
"newline-per-chained-call": "off",
"object-curly-spacing": [
"error",
"always"
],
"prefer-arrow-callback": 0,
"prefer-reflect": 0,
"prefer-template": 0,
"spaced-comment": [
"error",
"always",
{
"markers": [
"global",
"eslint"
]
}
],
"no-invalid-this": 0,
"dot-location": 0,
"eol-last": 2,
"func-names": 0,
"global-require": 0,
"require-jsdoc": 0,
"valid-jsdoc": 0,
"sort-keys": 0,
"prefer-destructuring": 0,
"indent": [
"error",
2,
{
"SwitchCase": 1
}
],
"jsx-quotes": [
"error",
"prefer-double"
],
"react/jsx-indent": [
"error",
2
],
"react/jsx-indent-props": [
"error",
2
],
"react/jsx-closing-bracket-location": [
1,
"line-aligned"
]
}
}
Looks like it's an Eslint error, but I have no idea how to fix it
@Aziaev It seems to be an issue with a version of eslint and babel-eslint. Try removing eslint from your project dependencies. It seems like you haven't ejected and CRA comes bundled with eslint already so you don't need to add it yourself
Ref: https://github.com/eslint/eslint/issues/9767
@kartiklad, when I have deleted eslint dependency from my package.json and clean node_modules a few times and rebooting my PC, and deleting package-lock.json problem was solved. Thank you
@kartiklad, unfortunately, that doesn't help
when I have deleted eslint setting from my package.json and reinstall all dependencies there appears a new error:
Error: C:\Users\user\WebstormProjects\app\node_modules\eslint-config-standard\index.js:
Configuration for rule "indent" is invalid:
Value "[object Object]" should NOT have additional properties.
Referenced from: C:\Users\user\WebstormProjects\app\.eslintrc
Error: C:\Users\user\WebstormProjects\app\node_modules\eslint-config-standard\index.js:
Configuration for rule "indent" is invalid:
Value "[object Object]" should NOT have additional properties.
Referenced from: C:\Users\user\WebstormProjects\app\.eslintrc
at validateRuleOptions (C:\Users\user\WebstormProjects\app\node_modules\eslint\lib\config\config-validator.js:113:15)
at Object.keys.forEach.id (C:\Users\user\WebstormProjects\app\node_modules\eslint\lib\config\config-validator.js:153:9)
at Array.forEach (<anonymous>)
at validateRules (C:\Users\user\WebstormProjects\app\node_modules\eslint\lib\config\config-validator.js:152:30)
at Object.validate (C:\Users\user\WebstormProjects\app\node_modules\eslint\lib\config\config-validator.js:230:5)
at loadFromDisk (C:\Users\user\WebstormProjects\app\node_modules\eslint\lib\config\config-file.js:549:19)
at load (C:\Users\user\WebstormProjects\app\node_modules\eslint\lib\config\config-file.js:592:20)
at configExtends.reduceRight (C:\Users\user\WebstormProjects\app\node_modules\eslint\lib\config\config-file.js:421:36)
at Array.reduceRight (<anonymous>)
at applyExtends (C:\Users\user\WebstormProjects\app\node_modules\eslint\lib\config\config-file.js:403:28)
Process finished with exit code -1
Both ways have an issue
@Aziaev Mate the solution to your problem is in the error message. The value for ident rule is not valid.
After changing eslint to use exact .eslintrc as a config file and keeping eslint 5.4.0 as devDependency, seems to issue is solved.
@kartiklad thanks