From 3dc7845303bd1e50c8d369aa521b2ffe7d04a795 Mon Sep 17 00:00:00 2001
From: "Timothy J. Warren"
Date: Fri, 30 Mar 2018 21:30:22 -0400
Subject: [PATCH] Linting rules
---
.eslintrc | 63 +++++++++++++++++++++++++++++++---
README.md | 7 ----
src/App.js | 18 +++++++---
src/App.test.js | 2 +-
src/components/Form.js | 25 ++++++++++++++
src/components/Grid.js | 8 ++---
src/components/index.js | 2 +-
src/electron/starter.js | 19 ++++++----
src/index.js | 2 +-
src/views/Camera/CameraList.js | 4 +--
src/views/index.js | 2 +-
11 files changed, 119 insertions(+), 33 deletions(-)
create mode 100644 src/components/Form.js
diff --git a/.eslintrc b/.eslintrc
index 975e5f9..704e91b 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -10,6 +10,7 @@
"plugin:inferno/recommended",
"eslint-config-happiness"
],
+ "globals": {},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
@@ -19,11 +20,63 @@
}
},
"rules": {
- "import/extensions": 0,
- "import/no-extraneous-dependencies": 0,
+ "array-callback-return": "error",
+ "camelcase": ["error", {
+ "properties": "never"
+ }],
+ "comma-dangle": ["error", "always-multiline"],
+ "import/extensions": "off",
+ "import/no-extraneous-dependencies": "off",
"import/no-unresolved": [2, { "ignore": ["electron"] }],
- "linebreak-style": 0,
- "react/prefer-stateless-function": 0,
- "no-console": 0
+ "jsx-quotes": ["error", "prefer-double"],
+ "linebreak-style": "off",
+ "multiline-ternary": ["error", "always-multiline"],
+ "prefer-arrow-callback": ["error", {
+ "allowNamedFunctions": true
+ }],
+ "prefer-const": "error",
+ "no-alert": "error",
+ "no-console": "off",
+ "no-duplicate-imports": "error",
+ "no-eval": "error",
+ "no-extend-native": "error",
+ "no-extra-bind": "error",
+ "no-extra-semi": "error",
+ "no-implied-eval": "error",
+ "no-invalid-this": "error",
+ "no-nested-ternary": "error",
+ "no-new-func": "error",
+ "no-new-wrappers": "error",
+ "no-return-assign": "error",
+ "no-return-await": "error",
+ "no-self-compare": "error",
+ "no-shadow": ["error", {
+ "builtinGlobals": true
+ }],
+ "no-unneeded-ternary": "error",
+ "no-unused-expressions": "error",
+ "no-use-before-define": "error",
+ "no-useless-call": "error",
+ "no-useless-concat": "error",
+ "no-useless-return": "error",
+ "no-var": "error",
+ "no-with": "error",
+ "prefer-rest-params": "error",
+ "prefer-spread": "error",
+ "prefer-template": "error",
+ "quotes": ["error", "single", {
+ "allowTemplateLiterals": true,
+ "avoidEscape": true
+ }],
+ "quote-props": ["error", "as-needed", {
+ "keywords": true,
+ "unnecessary": false,
+ "numbers": false
+ }],
+ "radix": ["error", "always"],
+ "react/prefer-stateless-function": "off",
+ "require-await": "error",
+ "sort-keys": ["error", "asc", {"caseSensitive": true, "natural": true}],
+ "yoda": ["error", "never"]
}
}
diff --git a/README.md b/README.md
index ed7703f..f7ff8b1 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,6 @@ You can find the most recent version of this guide [here](https://github.com/fac
- [npm test](#npm-test)
- [npm run build](#npm-run-build)
- [npm run eject](#npm-run-eject)
-- [Supported Browsers](#supported-browsers)
- [Supported Language Features and Polyfills](#supported-language-features-and-polyfills)
- [Syntax Highlighting in the Editor](#syntax-highlighting-in-the-editor)
- [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor)
@@ -198,12 +197,6 @@ Instead, it will copy all the configuration files and the transitive dependencie
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
-## Supported Browsers
-
-By default, the generated project uses the latest version of React.
-
-You can refer [to the React documentation](https://reactjs.org/docs/react-dom.html#browser-support) for more information about supported browsers.
-
## Supported Language Features and Polyfills
This project supports a superset of the latest JavaScript standard.
diff --git a/src/App.js b/src/App.js
index 4389fac..68e20f2 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,13 +1,14 @@
-import { version } from 'inferno';
-import { BrowserRouter, Route } from 'inferno-router'
+import { BrowserRouter } from 'inferno-router';
+
+import { Button, Form, FormGroup, Input, Label } from './components/Form';
import { Container, Row } from './components/Grid';
-const App = () => (
+const App = () => (
- {`Welcome to Inferno ${version}`}
+ Welcome to Inferno
@@ -15,6 +16,15 @@ const App = () => (
To get started, edit src/App.js
and save to reload.
+
+
+
);
diff --git a/src/App.test.js b/src/App.test.js
index b41b396..f3b7ca6 100644
--- a/src/App.test.js
+++ b/src/App.test.js
@@ -1,5 +1,5 @@
-import { render } from 'inferno';
import App from './App';
+import { render } from 'inferno';
it('renders without crashing', () => {
const div = document.createElement('div');
diff --git a/src/components/Form.js b/src/components/Form.js
new file mode 100644
index 0000000..7c78b62
--- /dev/null
+++ b/src/components/Form.js
@@ -0,0 +1,25 @@
+import Button from 'inferno-bootstrap/dist/Button';
+import Form from 'inferno-bootstrap/dist/Form/Form';
+import FormFeedback from 'inferno-bootstrap/dist/Form/FormFeedback';
+import FormGroup from 'inferno-bootstrap/dist/Form/FormGroup';
+import FormText from 'inferno-bootstrap/dist/Form/FormText';
+import Input from 'inferno-bootstrap/dist/Form/Input';
+import InputGroup from 'inferno-bootstrap/dist/Form/InputGroup';
+import InputGroupAddon from 'inferno-bootstrap/dist/Form/InputGroupAddon';
+import InputGroupButtonDropdown from 'inferno-bootstrap/dist/Form/InputGroupButtonDropdown';
+import InputGroupText from 'inferno-bootstrap/dist/Form/InputGroupText';
+import Label from 'inferno-bootstrap/dist/Form/Label';
+
+export {
+ Button,
+ Form,
+ FormFeedback,
+ FormGroup,
+ FormText,
+ Input,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButtonDropdown,
+ InputGroupText,
+ Label,
+};
diff --git a/src/components/Grid.js b/src/components/Grid.js
index b08f862..60abac7 100644
--- a/src/components/Grid.js
+++ b/src/components/Grid.js
@@ -1,9 +1,9 @@
-import Container from 'inferno-bootstrap/dist/Container'
-import Row from 'inferno-bootstrap/dist/Row'
-import Col from 'inferno-bootstrap/dist/Col'
+import Col from 'inferno-bootstrap/dist/Col';
+import Container from 'inferno-bootstrap/dist/Container';
+import Row from 'inferno-bootstrap/dist/Row';
export {
Col,
Container,
Row,
-}
+};
diff --git a/src/components/index.js b/src/components/index.js
index cdb349f..762542e 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -1 +1 @@
-export * from './Grid'
+export * from './Grid';
diff --git a/src/electron/starter.js b/src/electron/starter.js
index dd1ca12..52b7f14 100644
--- a/src/electron/starter.js
+++ b/src/electron/starter.js
@@ -11,18 +11,18 @@ const url = require('url');
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
-// This method will be called when Electron has finished
-// initialization and is ready to create browser windows.
-// Some APIs can only be used after this event occurs.
-app.on('ready', () => {
+const createWindow = () => {
// Create the browser window.
- mainWindow = new BrowserWindow({width: 800, height: 600});
+ mainWindow = new BrowserWindow({
+ height: 600,
+ width: 800,
+ });
// load the index.html of the app.
const startUrl = process.env.ELECTRON_START_URL || url.format({
pathname: path.join(__dirname, '/../../build/index.html'),
protocol: 'file:',
- slashes: true
+ slashes: true,
});
mainWindow.loadURL(startUrl);
// Open the DevTools.
@@ -35,7 +35,12 @@ app.on('ready', () => {
// when you should delete the corresponding element.
mainWindow = null;
});
-});
+};
+
+// This method will be called when Electron has finished
+// initialization and is ready to create browser windows.
+// Some APIs can only be used after this event occurs.
+app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', () => {
diff --git a/src/index.js b/src/index.js
index 894e538..55adc05 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,4 +1,4 @@
-import { render } from 'inferno';
import App from './App';
+import { render } from 'inferno';
render(, document.getElementById('app'));
diff --git a/src/views/Camera/CameraList.js b/src/views/Camera/CameraList.js
index 26cbe32..270c441 100644
--- a/src/views/Camera/CameraList.js
+++ b/src/views/Camera/CameraList.js
@@ -1,3 +1,3 @@
export const CameraList = () => {
- return
-}
+ return ;
+};
diff --git a/src/views/index.js b/src/views/index.js
index 51b9011..1a96124 100644
--- a/src/views/index.js
+++ b/src/views/index.js
@@ -1 +1 @@
-export * from './CameraList'
+export * from './Camera';