legacyDecorators not work, can not pass eslint when use decorator
didiself opened this issue · comments
Dipsy Pan commented
Hi, I google some solution but can not fixed it.
Pls help.
after insert "legacyDecorators": true,
, create new problem
It just error in eslint --fix
, function worded in product.
.eslintrc.js
module.exports = {
"env": {
"react-native/react-native": true,
"es6": true,
"node": true,
"jest": true
},
"extends": ["eslint:recommended", "plugin:prettier/recommended", 'plugin:react/recommended', "plugin:react-native/all"],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2019,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"legacyDecorators": true,
}
},
"plugins": [
"prettier",
"react",
"react-native"
],
"settings": {
"react": {
"pragma": "React", // Pragma to use, default to "React"
"version": "16.6.1", // React version, default to the latest React stable release
},
},
}
babel.config.js
module.exports = function(api) {
api.cache(true);
return {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
'babel-plugin-root-import',
{
rootPathPrefix: '~',
rootPathSuffix: './src',
},
],
[
'@babel/plugin-proposal-decorators',
{
legacy: true,
// decoratorsBeforeExport: true,
},
],
],
};
};
package.json
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-decorators": "^7.2.3",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"babel-plugin-root-import": "^6.1.0",
"babel-preset-react-native": "^4.0.1",
"code-push-cli": "^2.1.9",
"eslint": "^5.10.0",
"eslint-config-prettier": "^3.3.0",
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-react": "^7.11.1",
"eslint-plugin-react-native": "^3.5.0",
"husky": "^1.2.0",
"jest": "23.6.0",
"lint-staged": "^8.1.0",
"metro-react-native-babel-preset": "0.50.0",
"prettier": "^1.15.3",
"react-test-renderer": "16.6.1",
"redux-devtools-extension": "^2.13.7",
"source-map": "^0.7.3"
}
Nicolò Ribaudo commented
That error comes from prettier. You have to use the Babylon parser instead of the flow parser.
Dipsy Pan commented
That error comes from prettier. You have to use the Babylon parser instead of the flow parser.
resolved.
Thank you !