Include ESLint in react templates
This commit is contained in:
Ryan Brandenburg 2018-10-25 12:27:39 -07:00 committed by GitHub
parent 9b3d1f56fd
commit b05185f1f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 1407 additions and 1141 deletions

View File

@ -5,5 +5,7 @@
}, },
"[json]": { "[json]": {
"editor.tabSize": 2 "editor.tabSize": 2
} },
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"javascript.format.insertSpaceAfterConstructor": true
} }

View File

@ -4,6 +4,7 @@
"private": true, "private": true,
"dependencies": { "dependencies": {
"bootstrap": "^4.1.3", "bootstrap": "^4.1.3",
"jquery": "^3.3.1",
"react": "^16.0.0", "react": "^16.0.0",
"react-dom": "^16.0.0", "react-dom": "^16.0.0",
"react-router-bootstrap": "^0.24.4", "react-router-bootstrap": "^0.24.4",
@ -12,10 +13,25 @@
"reactstrap": "^6.3.0", "reactstrap": "^6.3.0",
"rimraf": "^2.6.2" "rimraf": "^2.6.2"
}, },
"devDependencies": {
"ajv": "^6.0.0",
"babel-eslint": "^7.2.3",
"cross-env": "^5.2.0",
"eslint": "^4.1.1",
"eslint-config-react-app": "^2.1.0",
"eslint-plugin-flowtype": "^2.50.3",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.11.1"
},
"eslintConfig": {
"extends": "react-app"
},
"scripts": { "scripts": {
"start": "rimraf ./build && react-scripts start", "start": "rimraf ./build && react-scripts start",
"build": "react-scripts build", "build": "react-scripts build",
"test": "react-scripts test --env=jsdom", "test": "cross-env CI=true react-scripts test --env=jsdom",
"eject": "react-scripts eject" "eject": "react-scripts eject",
"lint": "eslint ./src/"
} }
} }

View File

@ -6,9 +6,9 @@ import { FetchData } from './components/FetchData';
import { Counter } from './components/Counter'; import { Counter } from './components/Counter';
export default class App extends Component { export default class App extends Component {
displayName = App.name static displayName = App.name;
render() { render () {
return ( return (
<Layout> <Layout>
<Route exact path='/' component={Home} /> <Route exact path='/' component={Home} />

View File

@ -1,21 +1,21 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
export class Counter extends Component { export class Counter extends Component {
displayName = Counter.name static displayName = Counter.name;
constructor(props) { constructor (props) {
super(props); super(props);
this.state = { currentCount: 0 }; this.state = { currentCount: 0 };
this.incrementCounter = this.incrementCounter.bind(this); this.incrementCounter = this.incrementCounter.bind(this);
} }
incrementCounter() { incrementCounter () {
this.setState({ this.setState({
currentCount: this.state.currentCount + 1 currentCount: this.state.currentCount + 1
}); });
} }
render() { render () {
return ( return (
<div> <div>
<h1>Counter</h1> <h1>Counter</h1>

View File

@ -1,9 +1,9 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
export class FetchData extends Component { export class FetchData extends Component {
displayName = FetchData.name static displayName = FetchData.name;
constructor(props) { constructor (props) {
super(props); super(props);
this.state = { forecasts: [], loading: true }; this.state = { forecasts: [], loading: true };
@ -14,7 +14,7 @@ export class FetchData extends Component {
}); });
} }
static renderForecastsTable(forecasts) { static renderForecastsTable (forecasts) {
return ( return (
<table className='table table-striped'> <table className='table table-striped'>
<thead> <thead>
@ -39,7 +39,7 @@ export class FetchData extends Component {
); );
} }
render() { render () {
let contents = this.state.loading let contents = this.state.loading
? <p><em>Loading...</em></p> ? <p><em>Loading...</em></p>
: FetchData.renderForecastsTable(this.state.forecasts); : FetchData.renderForecastsTable(this.state.forecasts);

View File

@ -1,9 +1,9 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
export class Home extends Component { export class Home extends Component {
displayName = Home.name static displayName = Home.name;
render() { render () {
return ( return (
<div> <div>
<h1>Hello, world!</h1> <h1>Hello, world!</h1>
@ -13,7 +13,7 @@ export class Home extends Component {
<li><a href='https://facebook.github.io/react/'>React</a> for client-side code</li> <li><a href='https://facebook.github.io/react/'>React</a> for client-side code</li>
<li><a href='http://getbootstrap.com/'>Bootstrap</a> for layout and styling</li> <li><a href='http://getbootstrap.com/'>Bootstrap</a> for layout and styling</li>
</ul> </ul>
<p>To help you get started, we've also set up:</p> <p>To help you get started, we have also set up:</p>
<ul> <ul>
<li><strong>Client-side navigation</strong>. For example, click <em>Counter</em> then <em>Back</em> to return here.</li> <li><strong>Client-side navigation</strong>. For example, click <em>Counter</em> then <em>Back</em> to return here.</li>
<li><strong>Development server integration</strong>. In development mode, the development server from <code>create-react-app</code> runs in the background automatically, so your client-side resources are dynamically built on demand and the page refreshes when you modify any file.</li> <li><strong>Development server integration</strong>. In development mode, the development server from <code>create-react-app</code> runs in the background automatically, so your client-side resources are dynamically built on demand and the page refreshes when you modify any file.</li>

View File

@ -3,9 +3,9 @@ import { Container } from 'reactstrap';
import { NavMenu } from './NavMenu'; import { NavMenu } from './NavMenu';
export class Layout extends Component { export class Layout extends Component {
displayName = Layout.name static displayName = Layout.name;
render() { render () {
return ( return (
<div> <div>
<NavMenu /> <NavMenu />

View File

@ -1,12 +1,12 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Collapse, Container, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap'; import { Collapse, Container, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import './NavMenu.css'; import './NavMenu.css';
export class NavMenu extends Component { export class NavMenu extends Component {
displayName = NavMenu.name static displayName = NavMenu.name;
constructor(props) { constructor (props) {
super(props); super(props);
this.toggleNavbar = this.toggleNavbar.bind(this); this.toggleNavbar = this.toggleNavbar.bind(this);
@ -15,13 +15,13 @@ export class NavMenu extends Component {
}; };
} }
toggleNavbar() { toggleNavbar () {
this.setState({ this.setState({
collapsed: !this.state.collapsed collapsed: !this.state.collapsed
}); });
} }
render() { render () {
return ( return (
<header> <header>
<Navbar className="navbar-expand-sm navbar-toggleable-sm ng-white border-bottom box-shadow mb-3" light> <Navbar className="navbar-expand-sm navbar-toggleable-sm ng-white border-bottom box-shadow mb-3" light>

View File

@ -10,15 +10,15 @@
const isLocalhost = Boolean( const isLocalhost = Boolean(
window.location.hostname === 'localhost' || window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address. // [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' || window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4. // 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match( window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
) )
); );
export default function register() { export default function register () {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW. // 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);
@ -43,7 +43,7 @@ export default function register() {
} }
} }
function registerValidSW(swUrl) { function registerValidSW (swUrl) {
navigator.serviceWorker navigator.serviceWorker
.register(swUrl) .register(swUrl)
.then(registration => { .then(registration => {
@ -72,7 +72,7 @@ function registerValidSW(swUrl) {
}); });
} }
function checkValidServiceWorker(swUrl) { function checkValidServiceWorker (swUrl) {
// Check if the service worker can be found. If it can't reload the page. // Check if the service worker can be found. If it can't reload the page.
fetch(swUrl) fetch(swUrl)
.then(response => { .then(response => {
@ -99,7 +99,7 @@ function checkValidServiceWorker(swUrl) {
}); });
} }
export function unregister() { export function unregister () {
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => { navigator.serviceWorker.ready.then(registration => {
registration.unregister(); registration.unregister();

View File

@ -219,14 +219,15 @@
"integrity": "sha512-z55ocwKBRLryBs394Sm3ushTtBeg6VAeuku7utSoSnsJKvKcnXFIyC6vh27n3rXyxSgkJBBCAvyOn7gSUcTYjg==" "integrity": "sha512-z55ocwKBRLryBs394Sm3ushTtBeg6VAeuku7utSoSnsJKvKcnXFIyC6vh27n3rXyxSgkJBBCAvyOn7gSUcTYjg=="
}, },
"ajv": { "ajv": {
"version": "5.5.2", "version": "6.5.4",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.4.tgz",
"integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "integrity": "sha512-4Wyjt8+t6YszqaXnLDfMmG/8AlO5Zbcsy3ATHncCzjW/NoPzAId8AK6749Ybjmdt+kUY1gP60fCu46oDxPv/mg==",
"dev": true,
"requires": { "requires": {
"co": "^4.6.0", "fast-deep-equal": "^2.0.1",
"fast-deep-equal": "^1.0.0",
"fast-json-stable-stringify": "^2.0.0", "fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.3.0" "json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
} }
}, },
"ajv-keywords": { "ajv-keywords": {
@ -2242,11 +2243,6 @@
"resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz",
"integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=" "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4="
}, },
"co": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
"integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ="
},
"coa": { "coa": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/coa/-/coa-1.0.4.tgz", "resolved": "https://registry.npmjs.org/coa/-/coa-1.0.4.tgz",
@ -2415,7 +2411,8 @@
"contains-path": { "contains-path": {
"version": "0.1.0", "version": "0.1.0",
"resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz",
"integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=" "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=",
"dev": true
}, },
"content-disposition": { "content-disposition": {
"version": "0.5.2", "version": "0.5.2",
@ -2533,6 +2530,31 @@
"sha.js": "^2.4.8" "sha.js": "^2.4.8"
} }
}, },
"cross-env": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-5.2.0.tgz",
"integrity": "sha512-jtdNFfFW1hB7sMhr/H6rW1Z45LFqyI431m3qU6bFXcQ3Eh7LtBuG3h74o7ohHZ3crrRkkqHlo4jYHFPcjroANg==",
"dev": true,
"requires": {
"cross-spawn": "^6.0.5",
"is-windows": "^1.0.0"
},
"dependencies": {
"cross-spawn": {
"version": "6.0.5",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz",
"integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==",
"dev": true,
"requires": {
"nice-try": "^1.0.4",
"path-key": "^2.0.1",
"semver": "^5.5.0",
"shebang-command": "^1.2.0",
"which": "^1.2.9"
}
}
}
},
"cross-spawn": { "cross-spawn": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
@ -3359,7 +3381,6 @@
"resolved": "https://registry.npmjs.org/eslint/-/eslint-4.10.0.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.10.0.tgz",
"integrity": "sha512-MMVl8P/dYUFZEvolL8PYt7qc5LNdS2lwheq9BYa5Y07FblhcZqFyaUqlS8TW5QITGex21tV4Lk0a3fK8lsJIkA==", "integrity": "sha512-MMVl8P/dYUFZEvolL8PYt7qc5LNdS2lwheq9BYa5Y07FblhcZqFyaUqlS8TW5QITGex21tV4Lk0a3fK8lsJIkA==",
"requires": { "requires": {
"ajv": "^5.2.0",
"babel-code-frame": "^6.22.0", "babel-code-frame": "^6.22.0",
"chalk": "^2.1.0", "chalk": "^2.1.0",
"concat-stream": "^1.6.0", "concat-stream": "^1.6.0",
@ -3454,6 +3475,7 @@
"version": "0.3.2", "version": "0.3.2",
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz",
"integrity": "sha512-sfmTqJfPSizWu4aymbPr4Iidp5yKm8yDkHp+Ir3YiTHiiDfxh69mOUsmiqW6RZ9zRXFaF64GtYmN7e+8GHBv6Q==", "integrity": "sha512-sfmTqJfPSizWu4aymbPr4Iidp5yKm8yDkHp+Ir3YiTHiiDfxh69mOUsmiqW6RZ9zRXFaF64GtYmN7e+8GHBv6Q==",
"dev": true,
"requires": { "requires": {
"debug": "^2.6.9", "debug": "^2.6.9",
"resolve": "^1.5.0" "resolve": "^1.5.0"
@ -3475,6 +3497,7 @@
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.2.0.tgz", "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.2.0.tgz",
"integrity": "sha1-snA2LNiLGkitMIl2zn+lTphBF0Y=", "integrity": "sha1-snA2LNiLGkitMIl2zn+lTphBF0Y=",
"dev": true,
"requires": { "requires": {
"debug": "^2.6.8", "debug": "^2.6.8",
"pkg-dir": "^1.0.0" "pkg-dir": "^1.0.0"
@ -3484,6 +3507,7 @@
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz",
"integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=",
"dev": true,
"requires": { "requires": {
"path-exists": "^2.0.0", "path-exists": "^2.0.0",
"pinkie-promise": "^2.0.0" "pinkie-promise": "^2.0.0"
@ -3493,6 +3517,7 @@
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
"integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=",
"dev": true,
"requires": { "requires": {
"pinkie-promise": "^2.0.0" "pinkie-promise": "^2.0.0"
} }
@ -3501,6 +3526,7 @@
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz",
"integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=",
"dev": true,
"requires": { "requires": {
"find-up": "^1.0.0" "find-up": "^1.0.0"
} }
@ -3508,34 +3534,37 @@
} }
}, },
"eslint-plugin-flowtype": { "eslint-plugin-flowtype": {
"version": "2.39.1", "version": "2.50.3",
"resolved": "https://registry.npmjs.org/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.39.1.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.50.3.tgz",
"integrity": "sha512-RiQv+7Z9QDJuzt+NO8sYgkLGT+h+WeCrxP7y8lI7wpU41x3x/2o3PGtHk9ck8QnA9/mlbNcy/hG0eKvmd7npaA==", "integrity": "sha512-X+AoKVOr7Re0ko/yEXyM5SSZ0tazc6ffdIOocp2fFUlWoDt7DV0Bz99mngOkAFLOAWjqRA5jPwqUCbrx13XoxQ==",
"dev": true,
"requires": { "requires": {
"lodash": "^4.15.0" "lodash": "^4.17.10"
} }
}, },
"eslint-plugin-import": { "eslint-plugin-import": {
"version": "2.8.0", "version": "2.14.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.8.0.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.14.0.tgz",
"integrity": "sha512-Rf7dfKJxZ16QuTgVv1OYNxkZcsu/hULFnC+e+w0Gzi6jMC3guQoWQgxYxc54IDRinlb6/0v5z/PxxIKmVctN+g==", "integrity": "sha512-FpuRtniD/AY6sXByma2Wr0TXvXJ4nA/2/04VPlfpmUDPOpOY264x+ILiwnrk/k4RINgDAyFZByxqPUbSQ5YE7g==",
"dev": true,
"requires": { "requires": {
"builtin-modules": "^1.1.1",
"contains-path": "^0.1.0", "contains-path": "^0.1.0",
"debug": "^2.6.8", "debug": "^2.6.8",
"doctrine": "1.5.0", "doctrine": "1.5.0",
"eslint-import-resolver-node": "^0.3.1", "eslint-import-resolver-node": "^0.3.1",
"eslint-module-utils": "^2.1.1", "eslint-module-utils": "^2.2.0",
"has": "^1.0.1", "has": "^1.0.1",
"lodash.cond": "^4.3.0", "lodash": "^4.17.4",
"minimatch": "^3.0.3", "minimatch": "^3.0.3",
"read-pkg-up": "^2.0.0" "read-pkg-up": "^2.0.0",
"resolve": "^1.6.0"
}, },
"dependencies": { "dependencies": {
"doctrine": { "doctrine": {
"version": "1.5.0", "version": "1.5.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz",
"integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=",
"dev": true,
"requires": { "requires": {
"esutils": "^2.0.2", "esutils": "^2.0.2",
"isarray": "^1.0.0" "isarray": "^1.0.0"
@ -3544,12 +3573,14 @@
"isarray": { "isarray": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
"dev": true
}, },
"load-json-file": { "load-json-file": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz",
"integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=",
"dev": true,
"requires": { "requires": {
"graceful-fs": "^4.1.2", "graceful-fs": "^4.1.2",
"parse-json": "^2.2.0", "parse-json": "^2.2.0",
@ -3561,6 +3592,7 @@
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
"integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
"dev": true,
"requires": { "requires": {
"error-ex": "^1.2.0" "error-ex": "^1.2.0"
} }
@ -3569,19 +3601,22 @@
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz",
"integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=",
"dev": true,
"requires": { "requires": {
"pify": "^2.0.0" "pify": "^2.0.0"
} }
}, },
"pify": { "pify": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
}, },
"read-pkg": { "read-pkg": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz",
"integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=",
"dev": true,
"requires": { "requires": {
"load-json-file": "^2.0.0", "load-json-file": "^2.0.0",
"normalize-package-data": "^2.3.2", "normalize-package-data": "^2.3.2",
@ -3592,6 +3627,7 @@
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz",
"integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=",
"dev": true,
"requires": { "requires": {
"find-up": "^2.0.0", "find-up": "^2.0.0",
"read-pkg": "^2.0.0" "read-pkg": "^2.0.0"
@ -3614,23 +3650,36 @@
} }
}, },
"eslint-plugin-react": { "eslint-plugin-react": {
"version": "7.4.0", "version": "7.11.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.4.0.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.11.1.tgz",
"integrity": "sha512-tvjU9u3VqmW2vVuYnE8Qptq+6ji4JltjOjJ9u7VAOxVYkUkyBZWRvNYKbDv5fN+L6wiA+4we9+qQahZ0m63XEA==", "integrity": "sha512-cVVyMadRyW7qsIUh3FHp3u6QHNhOgVrLQYdQEB1bPWBsgbNCHdFAeNMquBMCcZJu59eNthX053L70l7gRt4SCw==",
"dev": true,
"requires": { "requires": {
"doctrine": "^2.0.0", "array-includes": "^3.0.3",
"has": "^1.0.1", "doctrine": "^2.1.0",
"jsx-ast-utils": "^2.0.0", "has": "^1.0.3",
"prop-types": "^15.5.10" "jsx-ast-utils": "^2.0.1",
"prop-types": "^15.6.2"
}, },
"dependencies": { "dependencies": {
"jsx-ast-utils": { "jsx-ast-utils": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz",
"integrity": "sha1-6AGxs5mF4g//yHtA43SAgOLcrH8=", "integrity": "sha1-6AGxs5mF4g//yHtA43SAgOLcrH8=",
"dev": true,
"requires": { "requires": {
"array-includes": "^3.0.3" "array-includes": "^3.0.3"
} }
},
"prop-types": {
"version": "15.6.2",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.6.2.tgz",
"integrity": "sha512-3pboPvLiWD7dkI3qf3KbUe6hKFKa52w+AE0VCqECtf+QHAKgOL37tTaNCnuX1nAAQ4ZhyP+kYVKf8rLmJ/feDQ==",
"dev": true,
"requires": {
"loose-envify": "^1.3.1",
"object-assign": "^4.1.1"
}
} }
} }
}, },
@ -3888,9 +3937,10 @@
"integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU="
}, },
"fast-deep-equal": { "fast-deep-equal": {
"version": "1.1.0", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz",
"integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=",
"dev": true
}, },
"fast-json-stable-stringify": { "fast-json-stable-stringify": {
"version": "2.0.0", "version": "2.0.0",
@ -4156,11 +4206,13 @@
}, },
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true "bundled": true,
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -4173,15 +4225,18 @@
}, },
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true "bundled": true,
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true "bundled": true,
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true "bundled": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -4284,7 +4339,8 @@
}, },
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true "bundled": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -4294,6 +4350,7 @@
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -4306,17 +4363,20 @@
"minimatch": { "minimatch": {
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
}, },
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true "bundled": true,
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.2.4", "version": "2.2.4",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.1", "safe-buffer": "^5.1.1",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -4333,6 +4393,7 @@
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -4405,7 +4466,8 @@
}, },
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true "bundled": true,
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -4415,6 +4477,7 @@
"once": { "once": {
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -4520,6 +4583,7 @@
"string-width": { "string-width": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -4814,7 +4878,6 @@
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz", "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz",
"integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==", "integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==",
"requires": { "requires": {
"ajv": "^5.3.0",
"har-schema": "^2.0.0" "har-schema": "^2.0.0"
} }
}, },
@ -6103,9 +6166,10 @@
"integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM="
}, },
"json-schema-traverse": { "json-schema-traverse": {
"version": "0.3.1", "version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"dev": true
}, },
"json-stable-stringify": { "json-stable-stringify": {
"version": "1.0.1", "version": "1.0.1",
@ -6316,11 +6380,6 @@
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
"integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=" "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY="
}, },
"lodash.cond": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/lodash.cond/-/lodash.cond-4.5.2.tgz",
"integrity": "sha1-9HGh2khr5g9quVXRcRVSPdHSVdU="
},
"lodash.debounce": { "lodash.debounce": {
"version": "4.0.8", "version": "4.0.8",
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
@ -6799,6 +6858,12 @@
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw="
}, },
"nice-try": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
"dev": true
},
"no-case": { "no-case": {
"version": "2.3.2", "version": "2.3.2",
"resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz", "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz",
@ -8915,10 +8980,7 @@
"eslint": "4.10.0", "eslint": "4.10.0",
"eslint-config-react-app": "^2.1.0", "eslint-config-react-app": "^2.1.0",
"eslint-loader": "1.9.0", "eslint-loader": "1.9.0",
"eslint-plugin-flowtype": "2.39.1",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-jsx-a11y": "5.1.1", "eslint-plugin-jsx-a11y": "5.1.1",
"eslint-plugin-react": "7.4.0",
"extract-text-webpack-plugin": "3.0.2", "extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.5", "file-loader": "1.1.5",
"fs-extra": "3.0.1", "fs-extra": "3.0.1",
@ -9478,10 +9540,7 @@
"schema-utils": { "schema-utils": {
"version": "0.3.0", "version": "0.3.0",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.3.0.tgz", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.3.0.tgz",
"integrity": "sha1-9YdyIs4+kx7a4DnxfrNxbnE3+M8=", "integrity": "sha1-9YdyIs4+kx7a4DnxfrNxbnE3+M8="
"requires": {
"ajv": "^5.0.0"
}
}, },
"select-hose": { "select-hose": {
"version": "2.0.0", "version": "2.0.0",
@ -10770,7 +10829,6 @@
"requires": { "requires": {
"acorn": "^5.0.0", "acorn": "^5.0.0",
"acorn-dynamic-import": "^2.0.0", "acorn-dynamic-import": "^2.0.0",
"ajv": "^5.1.5",
"ajv-keywords": "^2.0.0", "ajv-keywords": "^2.0.0",
"async": "^2.1.2", "async": "^2.1.2",
"enhanced-resolve": "^3.4.0", "enhanced-resolve": "^3.4.0",

View File

@ -16,10 +16,25 @@
"redux-thunk": "^2.2.0", "redux-thunk": "^2.2.0",
"rimraf": "^2.6.2" "rimraf": "^2.6.2"
}, },
"devDependencies": {
"ajv": "^6.0.0",
"babel-eslint": "^7.2.3",
"cross-env": "^5.2.0",
"eslint": "^4.1.1",
"eslint-config-react-app": "^2.1.0",
"eslint-plugin-flowtype": "^2.50.3",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.11.1"
},
"eslintConfig": {
"extends": "react-app"
},
"scripts": { "scripts": {
"start": "rimraf ./build && react-scripts start", "start": "rimraf ./build && react-scripts start",
"build": "react-scripts build", "build": "react-scripts build",
"test": "react-scripts test --env=jsdom", "test": "cross-env CI=true react-scripts test --env=jsdom",
"eject": "react-scripts eject" "eject": "react-scripts eject",
"lint": "eslint ./src/"
} }
} }

View File

@ -1,4 +1,4 @@
import React from 'react'; import React from 'react';
import { Route } from 'react-router'; import { Route } from 'react-router';
import Layout from './components/Layout'; import Layout from './components/Layout';
import Home from './components/Home'; import Home from './components/Home';

View File

@ -1,10 +1,10 @@
import React from 'react'; import React from 'react';
import { Collapse, Container, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap'; import { Collapse, Container, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import './NavMenu.css'; import './NavMenu.css';
export default class NavMenu extends React.Component { export default class NavMenu extends React.Component {
constructor(props) { constructor (props) {
super(props); super(props);
this.toggle = this.toggle.bind(this); this.toggle = this.toggle.bind(this);
@ -12,12 +12,12 @@ export default class NavMenu extends React.Component {
isOpen: false isOpen: false
}; };
} }
toggle() { toggle () {
this.setState({ this.setState({
isOpen: !this.state.isOpen isOpen: !this.state.isOpen
}); });
} }
render() { render () {
return ( return (
<header> <header>
<Navbar className="navbar-expand-sm navbar-toggleable-sm border-bottom box-shadow mb-3" light > <Navbar className="navbar-expand-sm navbar-toggleable-sm border-bottom box-shadow mb-3" light >

View File

@ -1,4 +1,4 @@
const incrementCountType = 'INCREMENT_COUNT'; const incrementCountType = 'INCREMENT_COUNT';
const decrementCountType = 'DECREMENT_COUNT'; const decrementCountType = 'DECREMENT_COUNT';
const initialState = { count: 0 }; const initialState = { count: 0 };

View File

@ -1,4 +1,4 @@
const requestWeatherForecastsType = 'REQUEST_WEATHER_FORECASTS'; const requestWeatherForecastsType = 'REQUEST_WEATHER_FORECASTS';
const receiveWeatherForecastsType = 'RECEIVE_WEATHER_FORECASTS'; const receiveWeatherForecastsType = 'RECEIVE_WEATHER_FORECASTS';
const initialState = { forecasts: [], isLoading: false }; const initialState = { forecasts: [], isLoading: false };

View File

@ -1,10 +1,10 @@
import { applyMiddleware, combineReducers, compose, createStore } from 'redux'; import { applyMiddleware, combineReducers, compose, createStore } from 'redux';
import thunk from 'redux-thunk'; import thunk from 'redux-thunk';
import { routerReducer, routerMiddleware } from 'react-router-redux'; import { routerReducer, routerMiddleware } from 'react-router-redux';
import * as Counter from './Counter'; import * as Counter from './Counter';
import * as WeatherForecasts from './WeatherForecasts'; import * as WeatherForecasts from './WeatherForecasts';
export default function configureStore(history, initialState) { export default function configureStore (history, initialState) {
const reducers = { const reducers = {
counter: Counter.reducer, counter: Counter.reducer,
weatherForecasts: WeatherForecasts.reducer weatherForecasts: WeatherForecasts.reducer

View File

@ -1,7 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using Xunit; using Xunit;
using Xunit.Abstractions; using Xunit.Abstractions;
@ -19,7 +21,7 @@ namespace Templates.Test
[Theory] [Theory]
[InlineData("Microsoft.DotNet.Web.ProjectTemplates")] [InlineData("Microsoft.DotNet.Web.ProjectTemplates")]
[InlineData("Microsoft.DotNet.Web.Spa.ProjectTemplates")] [InlineData("Microsoft.DotNet.Web.Spa.ProjectTemplates")]
public void CheckForByteOrderMark_InJsonFiles_ForAllTemplates(string projectType) public void CheckForByteOrderMark_ForAllTemplates(string projectType)
{ {
var currentDirectory = Directory.GetCurrentDirectory(); var currentDirectory = Directory.GetCurrentDirectory();
var repositoryPath = Directory.GetParent(currentDirectory).Parent.Parent.Parent.Parent.FullName; var repositoryPath = Directory.GetParent(currentDirectory).Parent.Parent.Parent.Parent.FullName;
@ -30,7 +32,8 @@ namespace Templates.Test
var filesWithBOMCharactersPresent = false; var filesWithBOMCharactersPresent = false;
foreach (var directory in directories) foreach (var directory in directories)
{ {
var files = Directory.GetFiles(directory, "*.json"); var files = (IEnumerable<string>)Directory.GetFiles(directory, "*.json");
files = files.Concat(Directory.GetFiles(directory, "*.js"));
foreach (var file in files) foreach (var file in files)
{ {
var filePath = Path.GetFullPath(file); var filePath = Path.GetFullPath(file);

View File

@ -60,5 +60,14 @@ namespace Templates.Test.Helpers
ProcessEx.RunViaShell(output, workingDirectory, "npm install"); ProcessEx.RunViaShell(output, workingDirectory, "npm install");
} }
} }
public static void Test(ITestOutputHelper outputHelper, string workingDirectory)
{
ProcessEx.RunViaShell(outputHelper, workingDirectory, "npm run lint");
if (!File.Exists(Path.Join(workingDirectory, "angular.json")))
{
ProcessEx.RunViaShell(outputHelper, workingDirectory, "npm run test");
}
}
} }
} }

View File

@ -36,14 +36,10 @@ namespace Templates.Test.SpaTemplateTest
// installs run concurrently which otherwise causes errors when tests run // installs run concurrently which otherwise causes errors when tests run
// in parallel. // in parallel.
var clientAppSubdirPath = Path.Combine(TemplateOutputDir, "ClientApp"); var clientAppSubdirPath = Path.Combine(TemplateOutputDir, "ClientApp");
if (File.Exists(Path.Combine(clientAppSubdirPath, "package.json"))) Assert.True(File.Exists(Path.Combine(clientAppSubdirPath, "package.json")), "Missing a package.json");
{
Npm.RestoreWithRetry(Output, clientAppSubdirPath); Npm.RestoreWithRetry(Output, clientAppSubdirPath);
} Npm.Test(Output, clientAppSubdirPath);
else if (File.Exists(Path.Combine(TemplateOutputDir, "package.json")))
{
Npm.RestoreWithRetry(Output, TemplateOutputDir);
}
TestApplication(targetFrameworkOverride, publish: false); TestApplication(targetFrameworkOverride, publish: false);
TestApplication(targetFrameworkOverride, publish: true); TestApplication(targetFrameworkOverride, publish: true);