Skip to content

Commit

Permalink
lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidWells committed Oct 25, 2016
1 parent a21ce71 commit 585f866
Show file tree
Hide file tree
Showing 93 changed files with 3,102 additions and 1,478 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,11 @@ Note: The `master` branch is the live site. **Never push directly to the master
If everything looks good on your unique netlify subdomain, you can go ahead and merge your branch to master on github.

Merging branches into master will trigger a site rebuild and `serverless.com` will be updated

# Phenomic

"transpile": "babel --ignore __tests__ --copy-files src --out-dir ../site/node_modules/phenomic/lib",


# ESLint ref
https://github.com/airbnb/javascript/blob/8468ed842314a5d66816927ba6c35f018035cffc/packages/eslint-config-airbnb/rules/react.js#L22-L33
39 changes: 14 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"offline": false
},
"scripts": {
"lintfix": "eslint --ignore-path .gitignore --fix .",
"lintfix": "eslint --ignore-path .gitignore --fix ./src",
"lint:js": "eslint --ignore-path .gitignore src",
"lint:css": "stylelint \"src/**/*.css\"",
"lint": "npm-run-all --parallel lint:*",
Expand All @@ -36,10 +36,9 @@
},
"devDependencies": {
"async": "^2.0.1",
"auth0-lock": "10.2.1",
"babel-cli": "^6.3.17",
"babel-core": "^6.3.26",
"babel-eslint": "^6.0.0-beta.0",
"babel-eslint": "^7.0.0",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
Expand All @@ -55,14 +54,12 @@
"directory-tree": "^1.1.0",
"download": "^5.0.2",
"eslint": "^3.7.1",
"eslint-config-standard": "^5.3.1",
"eslint-config-standard-react": "^2.4.0",
"eslint-loader": "^1.5.0",
"eslint-plugin-import": "^1.8.0",
"eslint-plugin-jsx-a11y": "^1.5.3",
"eslint-plugin-promise": "^2.0.1",
"eslint-plugin-react": "^5.1.1",
"eslint-plugin-standard": "^2.0.0",
"eslint-config-airbnb": "^12.0.0",
"eslint-plugin-flowtype": "^2.11.4",
"eslint-plugin-import": "^2.0.0",
"eslint-plugin-jsx-a11y": "^2.2.0",
"eslint-plugin-react": "^6.2.0",
"extract-text-webpack-plugin": "git://github.com/ServerlessInc/extract-text-webpack-plugin.git#webpack-1",
"file-loader": "^0.8.1",
"fs-extra": "^0.30.0",
Expand Down Expand Up @@ -92,7 +89,6 @@
"svgo": "^0.7.0",
"watch": "^1.0.1",
"webpack": "^1.12.1",
"whatwg-fetch": "^0.11.0",
"yamljs": "^0.2.8"
},
"babel": {
Expand All @@ -109,15 +105,6 @@
}
}
},
"eslintConfig": {
"parser": "babel-eslint",
"extends": [
"eslint-config-i-am-meticulous/react"
],
"rules": {
"react/prefer-stateless-function": 0
}
},
"eslintConfigRuleReact/prefer-stateless-function": "https://github.com/MoOx/phenomic/issues/46",
"stylelint": {
"extends": "stylelint-config-standard",
Expand All @@ -130,17 +117,19 @@
"axios": "^0.13.1",
"classnames": "^2.2.5",
"jwt-decode": "^2.1.0",
"phenomic": "0.17.8",
"lodash.debounce": "^4.0.8",
"phenomic": "0.17.10",
"react": "^15.0.0-rc.1",
"react-redux": "^4.4.1",
"react-router": "^2.3.0",
"react-svg-inline": "^1.1.0",
"react-auto-form": "^1.3.0",
"react-dom": "^15.0.0-rc.1",
"react-google-analytics": "^0.2.0",
"react-helmet": "^3.0.0",
"react-redux": "^4.4.1",
"react-router": "^2.3.0",
"react-svg-inline": "^1.1.0",
"redux": "^3.0.0",
"redux-thunk": "^2.1.0"
"redux-thunk": "^2.1.0",
"whatwg-fetch": "^0.11.0"
},
"dllPlugin": {
"path": "node_modules/@dummy-dll-folder"
Expand Down
8 changes: 4 additions & 4 deletions scripts/blog/config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/**
Constants used for blog processing scripts
*/
var path = require('path')
const path = require('path')
const projectRoot = path.join(__dirname, '..', '..')
const repoURL = 'https://github.com/serverless/blog'
var repoBranch = 'master'
const repoBranch = 'master'
/* uncomment out the line below to work locally with different blog branch
repoBranch = 'your-custom-repo-branch-here'
/**/

module.exports = {
repoURL: repoURL,
repoBranch: repoBranch,
repoURL,
repoBranch,
downloadLink: `${repoURL}/archive/${repoBranch}/.zip`,
// blogRepoPath: path.join(projectRoot, 'content-external/serverless-blog'),
// blogRepoPostPath: path.join(projectRoot, 'content-external/serverless-blog/posts/'),
Expand Down
2 changes: 1 addition & 1 deletion scripts/blog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ asyncLib.waterfall([
next(null, 'done')
})
},
], function (err, result) {
], (err, result) => {
if (err) {
console.log('err', err)
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/blog/notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Then you can push up those changes to the ${config.repoURL} repo
`

module.exports = function blogNotice () {
fs.writeFile(path.join(config.siteBlogPath, warningFile), contents, function (err) {
module.exports = function blogNotice() {
fs.writeFile(path.join(config.siteBlogPath, warningFile), contents, (err) => {
if (err) {
console.log(err)
}
Expand Down
10 changes: 5 additions & 5 deletions scripts/blog/remove-date-from-filename.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ const fs = require('fs-extra')
// remove YYYY-MM-DD from filename
const replacePattern = /[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])-/g

module.exports = function removeDateFromFileName (directoryPath, callBack) {
dir.files(directoryPath, function (err, files) {
module.exports = function removeDateFromFileName(directoryPath, callBack) {
dir.files(directoryPath, (err, files) => {
if (err) {
throw err
}
files.forEach(function (name) {
var newName = name.replace(replacePattern, '')
files.forEach((name) => {
const newName = name.replace(replacePattern, '')
if (name !== newName) {
fs.copy(name, newName, function (err) {
fs.copy(name, newName, (err) => {
if (err) {
console.log('error copying files')
return callBack(err)
Expand Down
8 changes: 4 additions & 4 deletions scripts/blog/sync-blog-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* TODO: depricate in favor of local github repo in here
* Utility for syncing blog on local machine for debugging etc
*/
var config = require('./config')
var path = require('path')
const config = require('./config')
const path = require('path')
const emptyDirectory = require('../utils/empty-directory')
const copyFiles = require('../utils/copy-files')
const blogRepoPath = config.blogRepoPath
const localBlogRepoPath = path.join(__dirname, '..', '..', '..', 'blog')

emptyDirectory(blogRepoPath, function () {
copyFiles(localBlogRepoPath, blogRepoPath, function (error) {
emptyDirectory(blogRepoPath, () => {
copyFiles(localBlogRepoPath, blogRepoPath, (error) => {
if (error) {
console.log(error)
console.log(`Blog not found at ${localBlogRepoPath}`)
Expand Down
4 changes: 2 additions & 2 deletions scripts/blog/sync-blog-remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const blogRepoPath = config.blogRepoPath
const downloadLink = config.downloadLink
const rimraf = require('rimraf')

rimraf(blogRepoPath, function () {
rimraf(blogRepoPath, () => {
console.log('empty local blog directory')
download(downloadLink, blogRepoPath, function (error) {
download(downloadLink, blogRepoPath, (error) => {
if (error) {
console.log(error)
console.log('DOWNLOAD ERROR')
Expand Down
38 changes: 19 additions & 19 deletions scripts/blog/update-blog-yaml.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
var fs = require('fs-extra')
var dir = require('node-dir')
var matter = require('gray-matter')
var jsonToYaml = require('yamljs')
var grabDateRegex = /[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/g
const fs = require('fs-extra')
const dir = require('node-dir')
const matter = require('gray-matter')
const jsonToYaml = require('yamljs')
const grabDateRegex = /[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/g

module.exports = function updateFileContents (filePath, callBack) {
module.exports = function updateFileContents(filePath, callBack) {
dir.readFiles(filePath, {
match: /.md$/,
//exclude: /^\./
}, function (err, content, filename, next) {
}, (err, content, filename, next) => {
if (err) throw err

// parse yaml frontmatter for title
var item = matter(content).data
const item = matter(content).data

item.gitLink = filename.split('blog')[1]
if (item.date) {
item.date = formatDate(item.date)
} else {
// if no date yaml defined, use filename
var date = filename.match(grabDateRegex)
const date = filename.match(grabDateRegex)
if (date) {
item.date = date[0]
}
}
var yaml = jsonToYaml.stringify(item)
const yaml = jsonToYaml.stringify(item)
// regex patterns to match frontmatter
// ---(\s*?.*?)*?---
// ^(---)(\s*?.*?)*?(---)
// ^---(\s*?.*?)*?---
var newYamlContent = `---
const newYamlContent = `---
${yaml}---`

var finalNewContent = content.replace(/^---(\s*?.*?)*?---/, newYamlContent)
const finalNewContent = content.replace(/^---(\s*?.*?)*?---/, newYamlContent)

fs.writeFileSync(filename, finalNewContent)

next()
},
function (err, files) {
(err, files) => {
if (err) {
callBack(err)
}
Expand All @@ -47,14 +47,14 @@ ${yaml}---`
)
}

function formatDate (date) {
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
function formatDate(date) {
let d = new Date(date),
month = `${d.getMonth() + 1}`,
day = `${d.getDate()}`,
year = d.getFullYear()

if (month.length < 2) month = '0' + month
if (day.length < 2) day = '0' + day
if (month.length < 2) month = `0${month}`
if (day.length < 2) day = `0${day}`

return [year, month, day].join('-')
}
24 changes: 12 additions & 12 deletions scripts/blog/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@ const cwd = process.cwd()
// var child = execSync('ls', { encoding: 'utf-8' }).trim();
const serverlessDocs = path.join(__dirname, '..', '..', 'serverless-blog', 'posts')

watch.createMonitor(serverlessDocs, function (monitor) {
monitor.on('created', function (f, stat) {
watch.createMonitor(serverlessDocs, (monitor) => {
monitor.on('created', (f, stat) => {
// Handle new files
})
monitor.on('changed', function (f, curr, prev) {
monitor.on('changed', (f, curr, prev) => {
// Handle file changes
console.log('changed file', f)

var command = 'npm run prepareContent'
var child = exec(command, {cwd: cwd}, function (error, stdout, stderr) {
const command = 'npm run prepareContent'
const child = exec(command, { cwd }, (error, stdout, stderr) => {
if (error) {
console.warn(error)
}
console.log(stdout)
console.log('Built components for consumer app')
})
child.stdout.on('data', function (data) {
console.log('stdout: ' + data)
child.stdout.on('data', (data) => {
console.log(`stdout: ${data}`)
})
child.stderr.on('data', function (data) {
console.log('stdout: ' + data)
child.stderr.on('data', (data) => {
console.log(`stdout: ${data}`)
})
child.on('close', function (code) {
console.log('closing code: ' + code)
child.on('close', (code) => {
console.log(`closing code: ${code}`)
})
// trigger pipepline
})
monitor.on('removed', function (f, stat) {
monitor.on('removed', (f, stat) => {
// Handle removed files
})
// monitor.stop(); // Stop watching
Expand Down
6 changes: 3 additions & 3 deletions scripts/build/build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Post install to build components
var cwd = process.cwd()
var path = require('path')
var exec = require('child_process').exec
const cwd = process.cwd()
const path = require('path')
const exec = require('child_process').exec

if (process.env.IS_NETLIFY_ENV) {
console.log('in NETLIFY_ENV context')
Expand Down
14 changes: 7 additions & 7 deletions scripts/build/component-usage-webpack-plugin.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var lookup = require('climb-lookup')
var packageJSONPath = lookup.lookupSync('package.json')
var packageInfo = require(packageJSONPath)
const lookup = require('climb-lookup')
const packageJSONPath = lookup.lookupSync('package.json')
const packageInfo = require(packageJSONPath)

function ComponentUsagePlugin (output, options) {
function ComponentUsagePlugin(output, options) {
this.options = options
}

ComponentUsagePlugin.prototype.apply = function apply (compiler) {
compiler.plugin('done', function (stats) {
var data = stats.toJson()
ComponentUsagePlugin.prototype.apply = function apply(compiler) {
compiler.plugin('done', (stats) => {
const data = stats.toJson()
// data has all files being used in project
console.log(data)

Expand Down
Loading

0 comments on commit 585f866

Please sign in to comment.