2017-06-15 72 views
0

我在Nextjs反應的應用程序時,當我運行npm run lint錯誤正在此錯誤:../../Projects/app/pages/index.js ESlint Parsing error: Unexpected token <所有.js文件在他們jsx的。所以,在我看來,eslint不喜歡有JSX在文件擴展名爲」 .js文件Nextjs Reactjs:意外的記號「<」錯誤使用eslint

這些都是我的巴貝爾eslint包:

"babel-cli": "^6.18.0", 
"babel-core": "^6.18.2", 
"babel-eslint": "^7.1.0", 
"babel-loader": "^6.2.7", 
"babel-plugin-rewire": "^1.0.0", 
"babel-plugin-transform-runtime": "^6.15.0", 
"babel-preset-latest": "^6.16.0", 
"babel-preset-react": "^6.16.0", 
"babel-preset-react-optimize": "^1.0.1", 
"babel-types": "^6.18.0", 
"eslint": "^3.9.1", 
"eslint-config-airbnb": "^13.0.0", 
"eslint-loader": "^1.6.1", 
"eslint-plugin-import": "^2.2.0", 
"eslint-plugin-jsx-a11y": "^2.2.3", 
"eslint-plugin-react": "^6.6.0", 
"webpack": "^1.13.3", 
"webpack-hot-middleware": "^2.13.2", 
"webpack-middleware": "^1.5.1" 

而這些是我的規則:

"babel": { 
"presets": [ 
    "react", 
    "latest" 
], 
"plugins": [ 
    "syntax-trailing-function-commas", 
    "transform-async-to-generator", 
    "transform-es2015-destructuring", 
    "transform-es2015-parameters", 
    "transform-es2015-duplicate-keys", 
    "transform-es2015-modules-commonjs", 
    "transform-exponentiation-operator", 
    "transform-runtime" 
], 
"env": { 
    "test": { 
    "plugins": [ 
     "rewire" 
    ] 
    } 
}}, 

Eslint配置:

"eslintConfig": { 
"parser": "babel-eslint", 
"extends": "airbnb", 
"env": { 
    "browser": true 
}, 
"rules": { 
    "jsx-quotes": [ 
    2, 
    "prefer-double" 
    ], 
    "no-confusing-arrow": 0, 
    "react/jsx-filename-extension": [ 
    1, 
    { 
     "extensions": [".js", ".jsx"] 
    } 
    ], 
    "react/jsx-quotes": 0, 
    "react/jsx-boolean-value": 0, 
    "jsx-a11y/anchor-has-content": "off", 
    "import/extensions": "off", 
    "comma-dangle": [ 
    2, 
    { 
     "arrays": "always-multiline", 
     "objects": "always-multiline", 
     "imports": "always-multiline", 
     "exports": "always-multiline", 
     "functions": "ignore" 
    } 
    ], 
    "no-plusplus": [ 
    2, 
    { 
     "allowForLoopAfterthoughts": true 
    } 
    ] 
}}, 

不知道如何解決這個問題,我已經檢查其他答案在線,但沒有幫助。設置具體規則 "rules": { "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }] } 也沒有幫助。代碼建立得很好,它只是棉絨失敗

+0

您是在LINTING或transpiling時發生錯誤嗎? –

+0

我正在將此作爲毛髮錯誤 – user988544

+0

你看過這個問題嗎? https://github.com/yannickcr/eslint-plugin-react/issues/447#issuecomment-184617282 –

回答

0

解決此answer。問題是我沒有編譯webpack配置代碼,因爲.babelrc會覆蓋webpack級別的配置文件