Client: lint config

This commit is contained in:
SamR1 2017-12-17 11:57:05 +01:00
parent ad2839ad63
commit b73fdd5e86
12 changed files with 12294 additions and 54 deletions

3
.gitignore vendored
View File

@ -29,4 +29,5 @@ build
npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn-error.log*
.eslintcache

477
mpwo_client/.eslintrc.json Normal file
View File

@ -0,0 +1,477 @@
{
"root": true,
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"module": true,
"experimentalObjectRestSpread": true
}
},
"env": {
"browser": true,
"node": true,
"es6": true,
"jest": true
},
"rules": {
"no-alert": "warn",
"no-array-constructor": "off",
"no-await-in-loop": "off",
"no-bitwise": "off",
"no-caller": "warn",
"no-case-declarations": "error",
"no-catch-shadow": "off",
"no-class-assign": "error",
"no-compare-neg-zero": "warn",
"no-cond-assign": "error",
"no-confusing-arrow": "off",
"no-console": [
"error",
{
"allow": [
"warn",
"error",
"info"
]
}
],
"no-const-assign": "error",
"no-constant-condition": "error",
"no-continue": "off",
"no-control-regex": "error",
"no-debugger": "off",
"no-delete-var": "error",
"no-div-regex": "off",
"no-dupe-args": "error",
"no-dupe-class-members": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "warn",
"no-else-return": "warn",
"no-empty": "error",
"no-empty-character-class": "error",
"no-empty-function": "off",
"no-empty-pattern": "error",
"no-eq-null": "warn",
"no-eval": "error",
"no-ex-assign": "error",
"no-extend-native": "error",
"no-extra-bind": "warn",
"no-extra-boolean-cast": "error",
"no-extra-label": "warn",
"no-extra-parens": "off",
"no-extra-semi": "off",
"no-fallthrough": "error",
"no-floating-decimal": "off",
"no-func-assign": "error",
"no-global-assign": "error",
"no-implicit-coercion": "off",
"no-implicit-globals": "off",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-inner-declarations": "error",
"no-invalid-regexp": "error",
"no-invalid-this": "error",
"no-irregular-whitespace": [
"warn",
{
"skipStrings": true,
"skipTemplates": true
}
],
"no-iterator": "off",
"no-label-var": "off",
"no-labels": "off",
"no-lone-blocks": "warn",
"no-lonely-if": "warn",
"no-loop-func": "warn",
"no-magic-numbers": "off",
"no-mixed-operators": "off",
"no-mixed-requires": "off",
"no-mixed-spaces-and-tabs": "error",
"no-multi-assign": "off",
"no-multi-spaces": "error",
"no-multi-str": "off",
"no-multiple-empty-lines": "warn",
"no-native-reassign": "off",
"no-negated-condition": "warn",
"no-negated-in-lhs": "off",
"no-nested-ternary": "off",
"no-new": "off",
"no-new-func": "off",
"no-new-object": "off",
"no-new-require": "off",
"no-new-symbol": "error",
"no-new-wrappers": "off",
"no-obj-calls": "error",
"no-octal": "error",
"no-octal-escape": "off",
"no-param-reassign": "off",
"no-path-concat": "warn",
"no-plusplus": "off",
"no-process-env": "off",
"no-process-exit": "off",
"no-proto": "off",
"no-prototype-builtins": "off",
"no-redeclare": "error",
"no-regex-spaces": "error",
"no-restricted-globals": "off",
"no-restricted-imports": "off",
"no-restricted-modules": "off",
"no-restricted-properties": "off",
"no-restricted-syntax": "off",
"no-return-assign": "off",
"no-return-await": "warn",
"no-script-url": "error",
"no-self-assign": "error",
"no-self-compare": "error",
"no-sequences": "warn",
"no-shadow": "warn",
"no-shadow-restricted-names": "warn",
"no-whitespace-before-property": "error",
"no-spaced-func": "off",
"no-sparse-arrays": "error",
"no-sync": "off",
"no-tabs": "error",
"no-ternary": "off",
"no-trailing-spaces": "error",
"no-this-before-super": "error",
"no-throw-literal": "warn",
"no-undef": "error",
"no-undef-init": "warn",
"no-undefined": "error",
"no-unexpected-multiline": "error",
"no-underscore-dangle": "off",
"no-unmodified-loop-condition": "off",
"no-unneeded-ternary": "error",
"no-unreachable": "error",
"no-unsafe-finally": "error",
"no-unsafe-negation": "error",
"no-unused-expressions": [
"error",
{
"allowShortCircuit": true,
"allowTernary": true
}
],
"no-unused-labels": "error",
"no-unused-vars": "error",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-computed-key": "off",
"no-useless-concat": "off",
"no-useless-constructor": "error",
"no-useless-escape": "warn",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-void": "off",
"no-var": "off",
"no-warning-comments": [
"warn",
{
"terms": [
"todo",
"fixme",
"xxx"
],
"location": "start"
}
],
"no-with": "off",
"array-bracket-spacing": [
"error",
"never"
],
"array-callback-return": "off",
"arrow-body-style": [
"error",
"as-needed"
],
"arrow-parens": [
"error",
"as-needed"
],
"arrow-spacing": "error",
"accessor-pairs": "off",
"block-scoped-var": "warn",
"block-spacing": "error",
"brace-style": [
"error",
"1tbs"
],
"callback-return": "off",
"camelcase": [
"warn", {
"properties": "never"
}],
"capitalized-comments": "off",
"class-methods-use-this": "off",
"comma-dangle": "off",
"comma-spacing": "error",
"comma-style": [
"error",
"last"
],
"complexity": "off",
"computed-property-spacing": [
"error",
"never"
],
"consistent-return": "off",
"consistent-this": "off",
"constructor-super": "error",
"curly": "error",
"default-case": "off",
"dot-location": [
"warn",
"property"
],
"dot-notation": "error",
"eol-last": "error",
"eqeqeq": [
"error",
"smart"
],
"func-call-spacing": "error",
"func-names": "off",
"func-name-matching": "off",
"func-style": "off",
"generator-star-spacing": "error",
"global-require": "off",
"guard-for-in": "warn",
"handle-callback-err": "off",
"id-blacklist": "off",
"id-length": "off",
"id-match": "off",
"indent": "off",
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "error",
"keyword-spacing": "error",
"linebreak-style": "error",
"line-comment-position": "off",
"lines-around-comment": "off",
"lines-around-directive": "off",
"max-depth": "warn",
"max-len": "error",
"max-lines": [
"warn",
500
],
"max-nested-callbacks": "warn",
"max-params": "off",
"max-statements": "off",
"max-statements-per-line": "error",
"multiline-ternary": "off",
"new-cap": "off",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "off",
"object-curly-newline": "off",
"object-curly-spacing": [
"error",
"always"
],
"object-property-newline": [
"error",
{
"allowMultiplePropertiesPerLine": true
}
],
"object-shorthand": "off",
"one-var": "off",
"one-var-declaration-per-line": "off",
"operator-assignment": "warn",
"operator-linebreak": "error",
"padded-blocks": "off",
"prefer-arrow-callback": "off",
"prefer-const": "warn",
"prefer-destructuring": "warn",
"prefer-numeric-literals": "warn",
"prefer-promise-reject-errors": "warn",
"prefer-reflect": "off",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "warn",
"quote-props": [
"error",
"as-needed"
],
"quotes": [
"warn",
"single", {
"avoidEscape": true
}
],
"radix": "off",
"require-await": "error",
"require-jsdoc": "off",
"require-yield": "error",
"rest-spread-spacing": "error",
"semi": [
"error",
"never"
],
"semi-spacing": "error",
"sort-keys": "off",
"sort-imports": "off",
"sort-vars": "off",
"space-before-blocks": "error",
"space-before-function-paren": "off",
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": "error",
"strict": "off",
"symbol-description": "off",
"template-curly-spacing": "off",
"template-tag-spacing": "off",
"unicode-bom": "error",
"use-isnan": "error",
"valid-jsdoc": "off",
"valid-typeof": "error",
"vars-on-top": "warn",
"wrap-iife": "off",
"wrap-regex": "off",
"no-template-curly-in-string": "warn",
"yield-star-spacing": "error",
"yoda": "off",
"react/display-name": "error",
"react/forbid-component-props": "off",
"react/forbid-prop-types": "off",
"react/no-array-index-key": "error",
"react/no-children-prop": "error",
"react/no-danger": "warn",
"react/no-danger-with-children": "error",
"react/no-deprecated": "error",
"react/no-did-mount-set-state": "error",
"react/no-did-update-set-state": "error",
"react/no-direct-mutation-state": "error",
"react/no-find-dom-node": "error",
"react/no-is-mounted": "error",
"react/no-multi-comp": "error",
"react/no-render-return-value": "error",
"react/no-set-state": "off",
"react/no-string-refs": "error",
"react/no-unescaped-entities": "error",
"react/no-unknown-property": "error",
"react/no-unused-prop-types": "off",
"react/prefer-es6-class": "error",
"react/prefer-stateless-function": "error",
"react/prop-types": "off",
"react/react-in-jsx-scope": "error",
"react/react-default-props": "off",
"react/require-optimization": "off",
"react/require-render-return": "error",
"react/self-closing-comp": "error",
"react/sort-comp": "error",
"react/sort-prop-types": "error",
"react/style-prop-object": "off",
"react/jsx-boolean-value": [
"error",
"never"
],
"react/jsx-closing-bracket-location": "error",
"react/jsx-curly-spacing": [
"error",
"never"
],
"react/jsx-equals-spacing": "error",
"react/jsx-filename-extension": "error",
"react/jsx-first-prop-new-line": [
"error",
"multiline-multiprop"
],
"react/jsx-handler-names": "error",
"react/jsx-indent": "off",
"react/jsx-indent-props": "off",
"react/jsx-key": "error",
"react/jsx-max-props-per-line": "off",
"react/jsx-no-bind": "off",
"react/jsx-no-comment-textnodes": "error",
"react/jsx-no-duplicate-props": "error",
"react/jsx-no-literals": "off",
"react/jsx-no-target-blank": "error",
"react/jsx-no-undef": "error",
"react/jsx-pascal-case": ["error", {
"ignore": ["_"]
}],
"react/jsx-sort-props": "off",
"react/jsx-tag-spacing": [
"error",
{
"beforeSelfClosing": "always"
}
],
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
"react/jsx-wrap-multilines": "error",
"import/no-unresolved": "error",
"import/named": "error",
"import/default": "error",
"import/namespace": "error",
"import/no-restricted-paths": "off",
"import/no-absolute-path": "error",
"import/no-dynamic-require": "off",
"import/no-internal-modules": "off",
"import/no-webpack-loader-syntax": "error",
"import/export": "error",
"import/no-named-as-default": "warn",
"import/no-named-as-default-member": "warn",
"import/no-deprecated": "warn",
"import/no-extraneous-dependencies": "warn",
"import/no-mutable-exports": "warn",
"import/unambiguous": "off",
"import/no-commonjs": "off",
"import/no-amd": "error",
"import/no-nodejs-modules": "off",
"import/first": "warn",
"import/no-duplicates": "error",
"import/no-namespace": "warn",
"import/extensions": "warn",
"import/order": [
"error",
{
"newlines-between": "always",
"groups": [
"builtin",
"external",
[
"parent",
"sibling",
"index"
]
]
}
],
"import/newline-after-import": [
"error",
{
"count": 1
}
],
"import/prefer-default-export": "off",
"import/max-dependencies": "off",
"import/no-unassigned-import": "off",
"import/no-named-default": "warn",
"import/no-anonymous-default-export": "off"
},
"plugins": [
"react",
"import"
],
"settings": {
"import/resolver": {
"node": {
"extensions": [
".js",
".jsx"
]
}
}
}
}

11747
mpwo_client/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,13 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"lint": "eslint --cache --ext .jsx --ext .js src"
},
"devDependencies": {
"babel-eslint": "^8.0.3",
"eslint": "^4.13.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-react": "^7.5.1"
}
}
}

View File

@ -1,8 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
});

View File

@ -0,0 +1,8 @@
import React from 'react'
import ReactDOM from 'react-dom'
import App from './components/App'
import registerServiceWorker from './registerServiceWorker'
ReactDOM.render(<App />, document.getElementById('root'))
registerServiceWorker()

View File

@ -1,8 +1,14 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import React from 'react'
import logo from '../logo.svg'
import './App.css'
class App extends React.Component {
constructor(props) {
super(props)
this.props = props
}
class App extends Component {
render() {
return (
<div className="App">
@ -14,8 +20,8 @@ class App extends Component {
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div>
);
)
}
}
export default App;
export default App

View File

@ -0,0 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
it('renders without crashing', () => {
const div = document.createElement('div')
ReactDOM.render(<App />, div)
})

View File

@ -1,5 +0,0 @@
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}

View File

@ -1,8 +1 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
require('./client.jsx')

View File

@ -16,30 +16,32 @@ const isLocalhost = Boolean(
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);
)
export default function register() {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
const publicUrl = new URL(process.env.PUBLIC_URL, window.location)
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
return;
// serve assets;
// see https://github.com/facebookincubator/create-react-app/issues/2374
return
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`
if (isLocalhost) {
// This is running on localhost. Lets check if a service worker still exists or not.
checkValidServiceWorker(swUrl);
// This is running on localhost.
// Lets check if a service worker still exists or not.
checkValidServiceWorker(swUrl)
} else {
// Is not local host. Just register service worker
registerValidSW(swUrl);
registerValidSW(swUrl)
}
});
})
}
}
@ -48,7 +50,7 @@ function registerValidSW(swUrl) {
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
const installingWorker = registration.installing
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
@ -56,20 +58,22 @@ function registerValidSW(swUrl) {
// the fresh content will have been added to the cache.
// It's the perfect time to display a "New content is
// available; please refresh." message in your web app.
console.log('New content is available; please refresh.');
// eslint-disable-next-line no-console
console.log('New content is available; please refresh.')
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// eslint-disable-next-line no-console
console.log('Content is cached for offline use.')
}
}
};
};
}
}
})
.catch(error => {
console.error('Error during service worker registration:', error);
});
console.error('Error during service worker registration:', error)
})
}
function checkValidServiceWorker(swUrl) {
@ -84,25 +88,26 @@ function checkValidServiceWorker(swUrl) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload();
});
});
window.location.reload()
})
})
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl);
registerValidSW(swUrl)
}
})
.catch(() => {
// eslint-disable-next-line no-console
console.log(
'No internet connection found. App is running in offline mode.'
);
});
)
})
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
registration.unregister();
});
registration.unregister()
})
}
}