Skip to content

Commit

Permalink
[SDPA-2712] Adds lint config, fixes for rule update in standard (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylankelly authored and tim-yao committed Jul 1, 2019
1 parent 7b0a6c6 commit eee31cb
Show file tree
Hide file tree
Showing 59 changed files with 374 additions and 278 deletions.
23 changes: 19 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
/build/
/config/
/dist/
/*.js
node_modules

/packages/**/node_modules
/examples/**/node_modules

# ignore nuxt module templates
packages/ripple-nuxt-tide/templates/*
packages/ripple-nuxt-tide/**/templates/*
packages/ripple-nuxt-ui/**/templates/*

# ignore storybook files
packages/ripple-ui-components/scripts

# Nuxt folders
/examples/**/dist
/examples/**/.nuxt

# Jest
coverage
3 changes: 3 additions & 0 deletions .sass-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ options:
files:
include:
- 'packages/**/*.scss'
- 'examples/**/*.scss'
exclude:
- 'node_modules/**/*.scss'
- 'packages/**/node_modules/**/*.scss'
- 'examples/**/node_modules/**/*.scss'
# Rule Configuration
rules:
indentation:
Expand Down
30 changes: 0 additions & 30 deletions examples/vic-gov-au/.eslintrc.js

This file was deleted.

19 changes: 16 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,29 @@
"start:example": "cd examples/vic-gov-au/ && yarn run dev",
"test:dev": "NODE_ENV=dev start-server-and-test start:example http://localhost:3000 cy:open",
"test:storybook": "cd packages/ripple-ui-components/ && yarn run test",
"cy:open": "cypress open"

"cy:open": "cypress open",
"lint": "eslint --ext .js,.vue . && sass-lint -qv --max-warnings 0",
"lint:fix": "eslint --ext .js,.vue . --fix"
},
"devDependencies": {
"lerna": "^3.0.0",
"cypress": "^3.1.5",
"cypress-axe": "^0.4.0",
"cypress-cucumber-preprocessor": "^1.11.0",
"axe-core": "^3.2.2",
"start-server-and-test": "^1.7.11"
"start-server-and-test": "^1.7.11",
"babel-eslint": "^10.0.1",
"eslint": "^5.11.1",
"@ljharb/eslint-config": "^13.1.1",
"eslint-config-standard": "^12.0.0",
"eslint-friendly-formatter": "^3.0.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jest": "^21.17.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",
"sass-lint": "^1.12.1"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
Expand Down
2 changes: 1 addition & 1 deletion packages/ripple-nuxt-tide/lib/core/mapping-filters.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Filters for adding extra process on a mapping value
import {getMimeType, getFormattedSize} from './tide-helper'
import { getMimeType, getFormattedSize } from './tide-helper'
// Create more filters if need.
export default {
paragraphKeyJourneyLinks: function (fieldParagraphLinks) {
Expand Down
2 changes: 1 addition & 1 deletion packages/ripple-nuxt-tide/lib/core/middleware-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export const additionalMiddleware = (modules) => {
...publicationMiddleWare
}
}
return {...moduleMiddleware}
return { ...moduleMiddleware }
}
2 changes: 1 addition & 1 deletion packages/ripple-nuxt-tide/lib/core/page-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import tideDefaultPageTypes from '../config/tide.page-types'
export const getTemplate = (type) => {
const defaultConfig = tideDefaultPageTypes.pageTemplates
// const customConfig = customPageTypes.pageTemplates
const pageTypes = {...defaultConfig}
const pageTypes = { ...defaultConfig }
return pageTypes[type]
}
18 changes: 9 additions & 9 deletions packages/ripple-nuxt-tide/lib/core/tide.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const apiPrefix = '/api/v1/'
export const tide = (axios, site, config) => ({
get: async function (resource, params = {}, id = '') {
const siteParam = 'site=' + site
const url = `${apiPrefix}${resource}${id ? `/${id}` : ''}?${siteParam}${Object.keys(params).length ? `&${qs.stringify(params, {indices: false})}` : ''}`
const url = `${apiPrefix}${resource}${id ? `/${id}` : ''}?${siteParam}${Object.keys(params).length ? `&${qs.stringify(params, { indices: false })}` : ''}`
let headers = {}

if (process.server || process.env.NODE_ENV === 'development') {
Expand All @@ -22,18 +22,18 @@ export const tide = (axios, site, config) => ({

// Set Session cookie if is available in parameters
if (typeof params.session_name !== 'undefined' && typeof params.session_value !== 'undefined') {
_.merge(headers, {Cookie: params.session_name + '=' + params.session_value})
_.merge(headers, { Cookie: params.session_name + '=' + params.session_value })
}

// Set 'X-CSRF-Token if token parameters is defined
if (typeof params.token !== 'undefined') {
_.merge(headers, {'X-CSRF-Token': params.token})
_.merge(headers, { 'X-CSRF-Token': params.token })
}

// Set 'X-Authorization' header if auth_token present
if (params.auth_token) {
if (!isTokenExpired(params.auth_token)) {
_.merge(headers, {'X-Authorization': `Bearer ${params.auth_token}`})
_.merge(headers, { 'X-Authorization': `Bearer ${params.auth_token}` })
} else {
delete config.headers['X-Authorization']
}
Expand All @@ -43,7 +43,7 @@ export const tide = (axios, site, config) => ({

// If headers is not empty add to config request
if (!_.isEmpty(headers)) {
_.merge(config, {headers: headers})
_.merge(config, { headers: headers })
}
return axios.$get(url, config)
},
Expand All @@ -58,7 +58,7 @@ export const tide = (axios, site, config) => ({
let headers = {
'Content-Type': 'application/vnd.api+json;charset=UTF-8'
}
_.merge(config, {headers: headers})
_.merge(config, { headers: headers })

return axios.$post(url, data, config)
},
Expand Down Expand Up @@ -110,7 +110,7 @@ export const tide = (axios, site, config) => ({
include.push(menuFields[menu])
}

const params = {include: include.toString()}
const params = { include: include.toString() }

let sitesData = await this.getSitesData(params)

Expand Down Expand Up @@ -216,7 +216,7 @@ export const tide = (axios, site, config) => ({
},

getPathData: async function (path, params) {
let routeParams = {path: path}
let routeParams = { path: path }
if (!_.isEmpty(params)) {
_.merge(routeParams, params)
}
Expand Down Expand Up @@ -284,7 +284,7 @@ export const tide = (axios, site, config) => ({
}
}
// remove undefined includes
let params = {include: include.filter(i => i).join(',')}
let params = { include: include.filter(i => i).join(',') }
// If query URL is not empty include in URL request
if (!_.isEmpty(query)) {
params = _.merge(query, params)
Expand Down
2 changes: 1 addition & 1 deletion packages/ripple-nuxt-tide/lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const nuxtTide = function (moduleOptions) {

this.addModule('@dpc-sdp/ripple-nuxt-ui')

this.options.head.htmlAttrs = this.options.head.hasOwnProperty('htmlAttrs') ? this.options.head.htmlAttrs : this.options.head.htmlAttrs = {lang: 'en'}
this.options.head.htmlAttrs = this.options.head.hasOwnProperty('htmlAttrs') ? this.options.head.htmlAttrs : this.options.head.htmlAttrs = { lang: 'en' }

this.addModule('@nuxtjs/proxy', true)

Expand Down
4 changes: 2 additions & 2 deletions packages/ripple-nuxt-tide/lib/pages/Tide.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default {
break
case 'news':
path = '/search'
filters = {'type': 'news'}
filters = { 'type': 'news' }
break
default:
path = '/search'
Expand All @@ -162,7 +162,7 @@ export default {
break
case 'rpl-accordion':
if (component.data.title) {
anchors.push({text: component.data.title, url: `#${kebabCase(component.data.title)}`})
anchors.push({ text: component.data.title, url: `#${kebabCase(component.data.title)}` })
}
break
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ripple-nuxt-tide/modules/alert/localstorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default ({ store, isHMR, app }) => {
paths: ['tideAlerts.dismissedAlerts'],
storage: {
getItem: key => Cookies.get(key),
setItem: (key, value) => Cookies.set(key, value, {expires: cookieExpiry ? inDaysFromNow(cookieExpiry) : null}),
setItem: (key, value) => Cookies.set(key, value, { expires: cookieExpiry ? inDaysFromNow(cookieExpiry) : null }),
removeItem: key => Cookies.remove(key)
}
})(store)
Expand Down
2 changes: 1 addition & 1 deletion packages/ripple-nuxt-tide/modules/alert/plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
async function getSiteAlert (app) {
try {
const response = await app.$tide.get(`node/alert`, {include: ['field_alert_type']})
const response = await app.$tide.get(`node/alert`, { include: ['field_alert_type'] })
const fetched = Date.now()

if (response.meta && response.meta.count > 0 && response.data.length > 0 && response.included) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ export default {
// If there's an existing token redirect to protected content
if (this.isAuthed) {
if (this.$route.query.destination !== undefined) {
this.$router.push({path: this.$route.query.destination})
this.$router.push({ path: this.$route.query.destination })
} else if (this.$props.redirect !== undefined) {
this.$router.push({path: this.$props.redirect})
this.$router.push({ path: this.$props.redirect })
} else {
this.$router.push({path: '/'})
this.$router.push({ path: '/' })
}
}
},
Expand All @@ -180,16 +180,16 @@ export default {
if (response.auth_token) {
this.$store.dispatch('tideAuthenticatedContent/setToken', response.auth_token)
if (this.$route.query.destination !== undefined) {
this.$router.push({path: this.$route.query.destination})
this.$router.push({ path: this.$route.query.destination })
} else if (this.$props.redirect !== undefined) {
this.$router.push({path: this.$props.redirect})
this.$router.push({ path: this.$props.redirect })
} else {
this.$router.push({path: '/'})
this.$router.push({ path: '/' })
}
}
this.forms[this.selectedForm].formState = {response: { status: 'success', message: this.currentForm.messages.success }}
this.forms[this.selectedForm].formState = { response: { status: 'success', message: this.currentForm.messages.success } }
} catch (e) {
this.forms[this.selectedForm].formState = {response: { status: 'danger', message: this.currentForm.messages.error }}
this.forms[this.selectedForm].formState = { response: { status: 'danger', message: this.currentForm.messages.error } }
}
},
switchForm (formKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
RplPageLayout,
TideLogin
},
asyncData ({route, store, redirect}) {
asyncData ({ route, store, redirect }) {
const isAuthed = Boolean(store.state.tideAuthenticatedContent.token)
if (isAuthed) {
if (route.query.destination !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ export default {
data.pass = this.forms.reset.model.pass
this.$tide.post('user/reset_password', data)
.then(r => {
this.forms.reset.formState = {response: {status: 'success', message: this.messages.success}}
this.forms.reset.formState = { response: { status: 'success', message: this.messages.success } }
})
.catch(e => {
this.forms.reset.formState = {response: {status: 'failed', message: this.messages.error}}
this.forms.reset.formState = { response: { status: 'failed', message: this.messages.error } }
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ripple-nuxt-tide/modules/event/mapping-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
location: mapping.filter(location, ['paragraphLocation']),
title: item.title,
summary: item.field_landing_page_summary,
link: {text: 'See event details', url: item.path.url}
link: { text: 'See event details', url: item.path.url }
}
})
} catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions packages/ripple-nuxt-tide/modules/event/pages/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default {
'url'
]
},
sort: {field: 'field_event_date_end_value', order: 'asc'},
sort: { field: 'field_event_date_end_value', order: 'asc' },
docType: 'event',
type: 'events'
}
Expand All @@ -106,7 +106,7 @@ export default {
location: source.field_event_details_event_locality[0] || '',
summary: typeof source.field_landing_page_summary !== 'undefined' ? this.truncateText(source.field_landing_page_summary[0]) : this.truncateText(source.body[0]),
image: source.field_media_image_absolute_path ? source.field_media_image_absolute_path[0] : '',
link: source.url && this.getLink(source.url, this.$store.state.tide.siteData.drupal_internal__tid, pSite, this.$store.state.tideSite.sitesDomainMap, {text: 'text', url: 'url'}, 'See event details')
link: source.url && this.getLink(source.url, this.$store.state.tide.siteData.drupal_internal__tid, pSite, this.$store.state.tideSite.sitesDomainMap, { text: 'text', url: 'url' }, 'See event details')
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ripple-nuxt-tide/modules/grant/pages/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default {
'funding_level'
]
},
sort: {field: 'title.keyword', order: 'asc'},
sort: { field: 'title.keyword', order: 'asc' },
docType: 'grant',
type: 'grant'
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ripple-nuxt-tide/modules/profile/pages/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default {
category: source.field_profile_category_name ? source.field_profile_category_name[0] : '',
lifespan: source.field_life_span ? this.truncateText(source.field_life_span[0], lifespanLimit) : '',
summary: typeof source.summary_processed !== 'undefined' && source.summary_processed[0].length > 1 ? this.truncateText(source.summary_processed[0], summaryLimit) : this.truncateText(source.field_landing_page_summary[0], summaryLimit),
link: this.getLink(source.url, this.$store.state.tide.siteData.drupal_internal__tid, source.field_node_primary_site, this.$store.state.tideSite.sitesDomainMap, {text: 'text', url: 'url'}, 'Read profile'),
link: this.getLink(source.url, this.$store.state.tide.siteData.drupal_internal__tid, source.field_node_primary_site, this.$store.state.tideSite.sitesDomainMap, { text: 'text', url: 'url' }, 'Read profile'),
image: source.field_media_image_absolute_path ? source.field_media_image_absolute_path[0] : ''
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import elasticApi from './lib/api'
import elasticClient from './lib/client'

export {elasticApi, elasticClient}
export { elasticApi, elasticClient }
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const searchMixin = {
truncateText: (text, stop = 150, clamp) => {
return truncateText(text, stop, clamp)
},
getLink: (urls, site, primarySite, domains, returnObj = {text: 'text', url: 'url'}, text) => {
getLink: (urls, site, primarySite, domains, returnObj = { text: 'text', url: 'url' }, text) => {
let siteIds = {}
let domain = ''
let path = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default {
let date = source.changed ? source.changed[0] : source.created[0]
return {
title: source.title[0],
link: this.getLink(source.url, site, source.field_node_primary_site, this.$store.state.tideSite.sitesDomainMap, {text: 'linkText', url: 'linkUrl'}),
link: this.getLink(source.url, site, source.field_node_primary_site, this.$store.state.tideSite.sitesDomainMap, { text: 'linkText', url: 'linkUrl' }),
date: this.validDate(date) ? date : '',
description: this.getDescription(source),
tags: []
Expand Down
6 changes: 3 additions & 3 deletions packages/ripple-nuxt-tide/modules/webform/mapping-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module.exports = {
field.values = []
for (let key in fields) {
if (fields.hasOwnProperty(key)) {
field.values.push({name: fields[key], value: key})
field.values.push({ name: fields[key], value: key })
}
}
break
Expand Down Expand Up @@ -265,7 +265,7 @@ module.exports = {
searchable: false,
showLabels: false
},
values: [{id: 'VIC', name: 'Victoria'}, {id: 'NSW', name: 'New South Wales'}, {id: 'WA', name: 'Western Australia'}, {id: 'QLD', name: 'Queensland'}, {id: 'ACT', name: 'Australian Capital Territory'}],
values: [{ id: 'VIC', name: 'Victoria' }, { id: 'NSW', name: 'New South Wales' }, { id: 'WA', name: 'Western Australia' }, { id: 'QLD', name: 'Queensland' }, { id: 'ACT', name: 'Australian Capital Territory' }],
styleClasses: ['form-group--col-two']
},
{
Expand Down Expand Up @@ -328,7 +328,7 @@ module.exports = {
if (group.hasOwnProperty('fields') && group.fields.length > 0) {
data.schema.groups.push(group)
} else if (!group.hasOwnProperty('fields') && field.type !== null) {
data.schema.groups.push({'fields': [field]})
data.schema.groups.push({ 'fields': [field] })
} else {
if (process.server) {
console.error(new Error(`Webform element type "${element['#type']}" is not supported in nuxt-tide at this stage, please ask site admin to remove it from relative Tide webform or addd support for it.`))
Expand Down
Loading

0 comments on commit eee31cb

Please sign in to comment.