diff --git a/.travis.yml b/.travis.yml index 5a85838..00c71d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,4 +15,4 @@ deploy: before_script: - npm install -script: npm run lint && npm run custom-tests && echo 'Done.' +script: npm test diff --git a/api/helpers/passport.js b/api/helpers/passport.js index 081f73c..3af349e 100644 --- a/api/helpers/passport.js +++ b/api/helpers/passport.js @@ -23,7 +23,7 @@ passport.serializeUser((user, next) => { next(null, user.id) }) passport.deserializeUser((id, next) => { - return User.findOne({id: id}) + return User.findOne({ id: id }) .then((user) => { next(null, user) return user @@ -37,7 +37,7 @@ function PassportHelper () { const strategies = sails.config.passport for (const key in strategies) { - let options = {passReqToCallback: true} + let options = { passReqToCallback: true } let Strategy = strategies[key].strategy if (key === 'local') { _.extend(options, { @@ -114,7 +114,7 @@ function PassportHelper () { if (profile.emails && profile.emails[0]) { userAttrs.email = profile.emails[0].value } if (!userAttrs.email) { return next(new Error('No email available')) } - const pass = await Passport.findOne({ + const passport = await Passport.findOne({ provider, identifier: q.identifier.toString() }) diff --git a/api/models/Book.js b/api/models/Book.js index 7971f47..11962de 100644 --- a/api/models/Book.js +++ b/api/models/Book.js @@ -17,10 +17,10 @@ module.exports = { unique: true, autoIncrement: true }, - title: {type: 'string', required: true}, - author: {type: 'string'}, - isbn: {type: 'string'}, - version: {type: 'string'} + title: { type: 'string', required: true }, + author: { type: 'string' }, + isbn: { type: 'string' }, + version: { type: 'string' } // ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗ // ║╣ ║║║╠╩╗║╣ ║║╚═╗ diff --git a/app.js b/app.js index f2c5f4e..edcec41 100644 --- a/app.js +++ b/app.js @@ -20,35 +20,31 @@ * https://sailsjs.com/anatomy/app.js */ - // Ensure we're in the project directory, so cwd-relative paths work as expected // no matter where we actually lift from. // > Note: This is not required in order to lift, but it is a convenient default. -process.chdir(__dirname); - - +process.chdir(__dirname) // Attempt to import `sails` dependency, as well as `rc` (for loading `.sailsrc` files). -var sails; -var rc; +var sails +var rc try { - sails = require('sails'); - rc = require('sails/accessible/rc'); + sails = require('sails') + rc = require('sails/accessible/rc') } catch (err) { - console.error('Encountered an error when attempting to require(\'sails\'):'); - console.error(err.stack); - console.error('--'); - console.error('To run an app using `node app.js`, you need to have Sails installed'); - console.error('locally (`./node_modules/sails`). To do that, just make sure you\'re'); - console.error('in the same directory as your app and run `npm install`.'); - console.error(); - console.error('If Sails is installed globally (i.e. `npm install -g sails`) you can'); - console.error('also run this app with `sails lift`. Running with `sails lift` will'); - console.error('not run this file (`app.js`), but it will do exactly the same thing.'); - console.error('(It even uses your app directory\'s local Sails install, if possible.)'); - return; -}//-• - + console.error('Encountered an error when attempting to require(\'sails\'):') + console.error(err.stack) + console.error('--') + console.error('To run an app using `node app.js`, you need to have Sails installed') + console.error('locally (`./node_modules/sails`). To do that, just make sure you\'re') + console.error('in the same directory as your app and run `npm install`.') + console.error() + console.error('If Sails is installed globally (i.e. `npm install -g sails`) you can') + console.error('also run this app with `sails lift`. Running with `sails lift` will') + console.error('not run this file (`app.js`), but it will do exactly the same thing.') + console.error('(It even uses your app directory\'s local Sails install, if possible.)') + return +}// -• // Start server -sails.lift(rc('sails')); +sails.lift(rc('sails')) diff --git a/assets/js/actions/login.js b/assets/js/actions/login.js index c35e747..5d690f1 100644 --- a/assets/js/actions/login.js +++ b/assets/js/actions/login.js @@ -53,9 +53,9 @@ export const setLoggedIn = (data) => (dispatch, getState) => { export const checkEmail = email => async (dispatch, getState) => { dispatch(setWorking(true)) dispatch(clearError()) - if (/^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(email)) { + if (/^([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,5})$/.test(email)) { try { - const res = await Ajax.post({ + await Ajax.post({ url: '/auth/email_exists', data: { email @@ -103,7 +103,7 @@ export const checkPassword = (email, password) => async (dispatch, getState) => export const signup = (email, password) => async (dispatch, getState) => { dispatch(setWorking(true)) dispatch(clearError()) - if (/^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(email)) { + if (/^([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,5})$/.test(email)) { try { await Ajax.post({ url: '/auth/email_available', diff --git a/assets/js/components/UnderlineInput.js b/assets/js/components/UnderlineInput.js index 0281a6a..2a5aeda 100644 --- a/assets/js/components/UnderlineInput.js +++ b/assets/js/components/UnderlineInput.js @@ -2,7 +2,7 @@ import React from 'react' -import STYLE from '../../styles/shared/underlineinput.scss' +import '../../styles/shared/underlineinput.scss' const UnderlineInput = props => (
diff --git a/assets/js/containers/Carousel.js b/assets/js/containers/Carousel.js index 3a5f4cc..ec6aaa4 100644 --- a/assets/js/containers/Carousel.js +++ b/assets/js/containers/Carousel.js @@ -1,7 +1,7 @@ 'use strict' import React from 'react' -import STYLE from '../../styles/shared/carousel.scss' +import '../../styles/shared/carousel.scss' class Carousel extends React.Component { constructor () { @@ -18,7 +18,7 @@ class Carousel extends React.Component { render () { return (
-
+
{this.props.children}
diff --git a/assets/js/login.js b/assets/js/login.js index 8524d4f..6295d50 100644 --- a/assets/js/login.js +++ b/assets/js/login.js @@ -3,12 +3,12 @@ import React from 'react' import ReactDOM from 'react-dom' import Progress from './components/Progress' -import Carousel, {CarouselItem} from './containers/Carousel' +import Carousel, { CarouselItem } from './containers/Carousel' import UnderlineInput from './components/UnderlineInput' import reducer from './reducers/login' -import {setEmail, setPassword, setCarousel, checkEmail, checkPassword, signup} from './actions/login' +import { setEmail, setPassword, setCarousel, checkEmail, checkPassword, signup } from './actions/login' -import STYLE from '../styles/login.scss' +import '../styles/login.scss' class App extends React.Component { constructor () { diff --git a/assets/js/reducers/login.js b/assets/js/reducers/login.js index 6495974..cf9d47f 100644 --- a/assets/js/reducers/login.js +++ b/assets/js/reducers/login.js @@ -3,7 +3,7 @@ import Actions from '../actions/login' const reducer = (state = {}, action) => { - const {type, data} = action + const { type, data } = action switch (type) { case Actions.set_user: return { diff --git a/config/env/development.js b/config/env/development.js index e01af2e..7326a6a 100644 --- a/config/env/development.js +++ b/config/env/development.js @@ -59,15 +59,15 @@ module.exports = { // -------------------------------------------------------------------------- /**************************************************************************** - *                         * + * * * More adapter-specific options * - *                         * + * * * > For example, for some hosted PostgreSQL providers (like Heroku), the * * > extra `ssl: true` option is mandatory and must be provided. * - *                         * - * More info:                   * - * https://sailsjs.com/config/datastores           * - *                         * + * * + * More info: * + * https://sailsjs.com/config/datastores * + * * ****************************************************************************/ // ssl: true, diff --git a/config/env/production.js b/config/env/production.js index c254b2e..229dd1b 100644 --- a/config/env/production.js +++ b/config/env/production.js @@ -59,15 +59,15 @@ module.exports = { // -------------------------------------------------------------------------- /**************************************************************************** - *                         * + * * * More adapter-specific options * - *                         * + * * * > For example, for some hosted PostgreSQL providers (like Heroku), the * * > extra `ssl: true` option is mandatory and must be provided. * - *                         * - * More info:                   * - * https://sailsjs.com/config/datastores           * - *                         * + * * + * More info: * + * https://sailsjs.com/config/datastores * + * * ****************************************************************************/ // ssl: true, diff --git a/config/protocols.js b/config/protocols.js index da7f609..de7dede 100644 --- a/config/protocols.js +++ b/config/protocols.js @@ -93,7 +93,7 @@ module.exports.protocols = { } } -const EMAIL_REGEX = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i +const EMAIL_REGEX = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i function validateEmail (email) { return EMAIL_REGEX.test(email) diff --git a/package.json b/package.json index d0aca63..90492e3 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@babel/polyfill": "^7.0.0", "@babel/preset-env": "^7.1.0", "@babel/preset-react": "^7.0.0", + "babel-eslint": "^10.0.1", "babel-loader": "^8.0.4", "css-loader": "^1.0.1", "eslint": "^5.8.0", @@ -76,7 +77,12 @@ }, "standard": { "globals": [ - "sails" - ] + "sails", + "User", + "Book", + "Passport", + "_" + ], + "parser": "babel-eslint" } } diff --git a/tasks/config/hash.js b/tasks/config/hash.js index 24ad26b..7f5439b 100644 --- a/tasks/config/hash.js +++ b/tasks/config/hash.js @@ -19,7 +19,7 @@ module.exports = function (grunt) { hashLength: 8, hashFunction: function (source, encoding) { if (!source || !encoding) { - throw new Error('Consistency violation: Cannot compute unique hash for production .css/.js cache-busting suffix, because `source` and/or `encoding` are falsey-- but they should be truthy strings! Here they are, respectively:\nsource: ' + require('util').inspect(source, {depth: null}) + '\nencoding: ' + require('util').inspect(encoding, {depth: null})) + throw new Error('Consistency violation: Cannot compute unique hash for production .css/.js cache-busting suffix, because `source` and/or `encoding` are falsey-- but they should be truthy strings! Here they are, respectively:\nsource: ' + require('util').inspect(source, { depth: null }) + '\nencoding: ' + require('util').inspect(encoding, { depth: null })) } return require('crypto').createHash('sha1').update(source, encoding).digest('hex') }