Kaynağa Gözat

Use babel-eslint and fix lint errors

Andrew Swistak 6 yıl önce
ebeveyn
işleme
8b1383d85f

+ 1 - 0
.eslintrc.js

@@ -13,6 +13,7 @@ module.exports = {
     Atomics: 'readonly',
     SharedArrayBuffer: 'readonly'
   },
+  parser: "babel-eslint",
   parserOptions: {
     ecmaFeatures: {
       jsx: true

+ 0 - 0
app/javascript/packs/frontend.js → app/javascript/packs/frontend.jsx


+ 17 - 19
app/javascript/packs/frontend/app.jsx

@@ -10,27 +10,25 @@ const TestComponent = lazy(() => import('./components/test_component'));
 
 import './assets/stylesheets/app.scss';
 
-class App extends React.Component {
-  render() {
-    return (
-      <BrowserRouter>
-        <Suspense fallback={<div>Loading...</div>}>
-          <ApplicationLayout>
-            <Switch>
-              <Route exact path='/' component={TestComponent} />
-              <Route path='/pokemon' component={Pokemon} />
+function App() {
+  return (
+    <BrowserRouter>
+      <Suspense fallback={<div>Loading...</div>}>
+        <ApplicationLayout>
+          <Switch>
+            <Route component={TestComponent} exact path='/' />
+            <Route component={Pokemon} path='/pokemon' />
 
-              <Route component={NotFound} />
-            </Switch>
+            <Route component={NotFound} />
+          </Switch>
 
-            <p>
-              <Link to='/pokemon'>Show me the pokemon!</Link>
-            </p>
-          </ApplicationLayout>
-        </Suspense>
-      </BrowserRouter>
-    );
-  }
+          <p>
+            <Link to='/pokemon'>Show me the pokemon!</Link>
+          </p>
+        </ApplicationLayout>
+      </Suspense>
+    </BrowserRouter>
+  );
 }
 
 export default hot(App);

+ 1 - 0
package.json

@@ -35,6 +35,7 @@
     "@babel/preset-env": "^7.4.3",
     "@babel/preset-react": "^7.0.0",
     "babel-core": "^7.0.0-bridge.0",
+    "babel-eslint": "^10.0.1",
     "babel-jest": "^24.7.1",
     "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
     "enzyme": "^3.9.0",

+ 20 - 0
yarn.lock

@@ -1568,6 +1568,18 @@ babel-core@^7.0.0-bridge.0:
   resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece"
   integrity sha512-poPX9mZH/5CSanm50Q+1toVci6pv5KSRv/5TWCwtzQS5XEwn40BcCrgIeMFWP9CKKIniKXNxoIOnOq4VVlGXhg==
 
+babel-eslint@^10.0.1:
+  version "10.0.1"
+  resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.1.tgz#919681dc099614cd7d31d45c8908695092a1faed"
+  integrity sha512-z7OT1iNV+TjOwHNLLyJk+HN+YVWX+CLE6fPD2SymJZOZQBs+QIexFjhm4keGTm8MW9xr4EC9Q0PbaLB24V5GoQ==
+  dependencies:
+    "@babel/code-frame" "^7.0.0"
+    "@babel/parser" "^7.0.0"
+    "@babel/traverse" "^7.0.0"
+    "@babel/types" "^7.0.0"
+    eslint-scope "3.7.1"
+    eslint-visitor-keys "^1.0.0"
+
 babel-jest@^24.7.1:
   version "24.7.1"
   resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-24.7.1.tgz#73902c9ff15a7dfbdc9994b0b17fcefd96042178"
@@ -3282,6 +3294,14 @@ eslint-plugin-react@^7.12.4:
     prop-types "^15.6.2"
     resolve "^1.9.0"
 
+eslint-scope@3.7.1:
+  version "3.7.1"
+  resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"
+  integrity sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=
+  dependencies:
+    esrecurse "^4.1.0"
+    estraverse "^4.1.1"
+
 eslint-scope@^4.0.0, eslint-scope@^4.0.3:
   version "4.0.3"
   resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848"