Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint all JavaScript files #605

Merged
merged 3 commits into from
Mar 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions events/country-map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
'use strict'

module.exports = {
EG: 'Africa',
ES: 'Africa',
KE: 'Africa',
MA: 'Africa',
MU: 'Africa',
NG: 'Africa',
ZA: 'Africa',
AE: 'Asia',
BD: 'Asia',
CN: 'Asia',
HK: 'Asia',
ID: 'Asia',
IL: 'Asia',
IN: 'Asia',
LB: 'Asia',
JP: 'Asia',
KR: 'Asia',
LK: 'Asia',
NP: 'Asia',
PH: 'Asia',
RU: 'Asia',
SA: 'Asia',
TH: 'Asia',
TW: 'Asia',
VN: 'Asia',
AT: 'Europe',
BE: 'Europe',
BY: 'Europe',
CH: 'Europe',
CZ: 'Europe',
DE: 'Europe',
DK: 'Europe',
EE: 'Europe',
FI: 'Europe',
FR: 'Europe',
GB: 'Europe',
GH: 'Europe',
GR: 'Europe',
HR: 'Europe',
HU: 'Europe',
IE: 'Europe',
IS: 'Europe',
IT: 'Europe',
LT: 'Europe',
LU: 'Europe',
ME: 'Europe',
MT: 'Europe',
NL: 'Europe',
NO: 'Europe',
PL: 'Europe',
PT: 'Europe',
RO: 'Europe',
RS: 'Europe',
SE: 'Europe',
SI: 'Europe',
SK: 'Europe',
TR: 'Europe',
UA: 'Europe',
CA: 'North America',
US: 'North America',
AR: 'Latin America',
BR: 'Latin America',
CL: 'Latin America',
CO: 'Latin America',
DO: 'Latin America',
EC: 'Latin America',
GT: 'Latin America',
MX: 'Latin America',
PA: 'Latin America',
PE: 'Latin America',
UY: 'Latin America',
VE: 'Latin America',
AU: 'South Pacific',
NZ: 'South Pacific',
SG: 'South Pacific'
}
63 changes: 38 additions & 25 deletions events/pull-meetup.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
const request = require('request').defaults({json: true, headers: {'user-agent': 'pull-meeting-0.1'}}),
url = 'https://api.meetup.com/2/groups',
auth = process.env.MEETUP_TOKEN,
qs = require('querystring'),
yml = require('./yaml-sync'),
opts =
{ topic: 'nodejs', category: 34, upcoming_events: true, key: auth
},
allresults = [],
u = url + '?' + qs.stringify(opts)

const countryMap =
{ ES: 'Africa', MU: 'Africa', NG: 'Africa', KE: 'Africa', ZA: 'Africa', MA: 'Africa', EG: 'Africa', IL: 'Asia', TH: 'Asia', KR: 'Asia', RU: 'Asia', ID: 'Asia', PH: 'Asia', IN: 'Asia', HK: 'Asia', CN: 'Asia', VN: 'Asia', TW: 'Asia', LK: 'Asia', NP: 'Asia', JP: 'Asia', AE: 'Asia', BD: 'Asia', LT: 'Europe', RS: 'Europe', HR: 'Europe', CZ: 'Europe', PT: 'Europe', TR: 'Europe', GR: 'Europe', DE: 'Europe', RO: 'Europe', MT: 'Europe', GH: 'Europe', IE: 'Europe', FI: 'Europe', SE: 'Europe', UA: 'Europe', AT: 'Europe', HU: 'Europe', CH: 'Europe', IS: 'Europe', GB: 'Europe', DK: 'Europe', EE: 'Europe', BE: 'Europe', NO: 'Europe', NL: 'Europe', FR: 'Europe', PL: 'Europe', SK: 'Europe', IT: 'Europe', SI: 'Europe', LU: 'Europe', BY: 'Europe', ME: 'Europe', CA: 'North America', US: 'North America', DO: 'Latin America', AR: 'Latin America', PE: 'Latin America', MX: 'Latin America', BR: 'Latin America', VE: 'Latin America', CL: 'Latin America', CO: 'Latin America', UY: 'Latin America', PA: 'Latin America', GT: 'Latin America', EC: 'Latin America', AU: 'South Pacific', SG: 'South Pacific', NZ: 'South Pacific'
'use strict'

const request = require('request')

const countryMap = require('./country-map')
const yml = require('./yaml-sync')
const pkg = require('../package')

const defaults = {
headers: { 'user-agent': `${pkg.name}/${pkg.version}` },
json: true
}
const results = []

function clean (event) {
delete event.topics
Expand All @@ -37,22 +36,36 @@ function finish (events) {
// This is nice when testing if you cache the response
// finish(JSON.parse(require('fs').readFileSync('./meetup.json').toString()))

function _go (u) {
request(u, (e, resp, body) => {
const results = body.results
results.forEach((result) => {
function pull (opts) {
request(opts, (err, resp, body) => {
if (err || resp.statusCode !== 200) {
throw (err || new Error(`Invalid status code (${resp.statusCode})`))
}

body.results.forEach((result) => {
const title = result.name.toLowerCase()
if (title.indexOf('nodeschool') !== -1) return
if (title.indexOf('mongodb') !== -1 && title.indexOf('node') === -1) return
if (title.indexOf('find a tech job') !== -1 && title.indexOf('node') === -1) return
// if (title.indexOf('node') !== -1) return allresults.push(result)
allresults.push(result)

if (title.includes('nodeschool')) return
if (title.includes('mongodb') && title.includes('node')) return
if (title.includes('find a tech job') && title.includes('node')) return

results.push(result)
})

if (body.meta.next) {
_go(body.meta.next)
pull(Object.assign({ url: body.meta.next }, defaults))
} else {
finish(allresults)
finish(results)
}
})
}
_go(u)

pull(Object.assign({
url: 'https://api.meetup.com/2/groups',
qs: {
key: process.env.MEETUP_TOKEN,
upcoming_events: true,
topic: 'nodejs',
category: 34
}
}, defaults))
31 changes: 20 additions & 11 deletions events/pull-nodeschool.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
'use strict'

const request = require('request'),
yml = require('./yaml-sync'),
nodeGeocoder = require('node-geocoder'),
geoOpts = {
apiKey: process.env.MAPS_TOKEN,
formatter: null
},
geocoder = nodeGeocoder('google', 'https', geoOpts)

request('http://nodeschool.io/chapters/list.json', {json: true}, (e, resp, list) => {
if (e || resp.statusCode !== 200) throw (e || new Error('response not 200' + resp.statusCode))
const nodeGeocoder = require('node-geocoder')
const request = require('request')

const yml = require('./yaml-sync')
const pkg = require('../package')

const geocoder = nodeGeocoder('google', 'https', {
apiKey: process.env.MAPS_TOKEN,
formatter: null
})

request({
headers: { 'user-agent': `${pkg.name}/${pkg.version}` },
url: 'http://nodeschool.io/chapters/list.json',
json: true
}, (err, resp, list) => {
if (err || resp.statusCode !== 200) {
throw (err || new Error(`Invalid status code (${resp.statusCode})`))
}

let count = 0
const chapters = []

Expand Down
49 changes: 22 additions & 27 deletions events/yaml-sync.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
var yaml = require('js-yaml'),
fs = require('fs'),
path = require('path'),
p = path.join(__dirname, '..', 'locale', 'en', 'get-involved', 'events.md'),
buf = fs.readFileSync(p),
lines = buf.toString().split('\n'),
str = lines.slice(lines.indexOf('---') + 1, lines.indexOf('---', lines.indexOf('---') + 1)).join('\n'),
store = yaml.safeLoad(str)
'use strict'

exports.getRegion = (region) => {
let reg;
const yaml = require('js-yaml')
const fs = require('fs')
const path = require('path')

const p = path.join(__dirname, '..', 'locale', 'en', 'get-involved', 'events.md')
const lines = fs.readFileSync(p).toString().split('\n')
const begin = lines.indexOf('---') + 1
const end = lines.indexOf('---', begin)
const store = yaml.safeLoad(lines.slice(begin, end).join('\n'))

function getRegion (region) {
let reg
for (reg in store.regions) {
if (store.regions[reg].region === region) return store.regions[reg]
}
Expand All @@ -17,15 +20,15 @@ exports.getRegion = (region) => {
return reg
}

exports.removeEmpty = (dict) => {
function removeEmpty (dict) {
for (const i in dict) {
if (!dict[i]) delete dict[i]
}
}

exports.replace = (list, key, keyValue, value) => {
exports.removeEmpty(value)
for (let i = 0;i < list.length;i++) {
function replace (list, key, keyValue, value) {
removeEmpty(value)
for (let i = 0; i < list.length; i++) {
if (list[i][key] === keyValue) {
list[i] = value
return
Expand All @@ -34,20 +37,12 @@ exports.replace = (list, key, keyValue, value) => {
list.push(value)
}

exports.save = () => {
function save () {
const str = ['---', yaml.dump(store), '---'].join('\n')
fs.writeFileSync(p, str)
}

function rebalance () {
store.regions = store.regions.slice(0, 6)
exports.save()
}

function clearMeetups () {
store.regions.forEach((reg) => {
delete reg.meetups
})
exports.save()
}
// clearMeetups()
exports.removeEmpty = removeEmpty
exports.getRegion = getRegion
exports.replace = replace
exports.save = save
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"load-versions": "node scripts/load-versions.js",
"start": "npm run serve",
"test": "npm run test:lint && npm run test:unit && npm run test:smoke",
"test:lint": "standard *.js scripts/*.js scripts/**/*.js tests/*.js tests/**/*.js",
"test:lint": "standard",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"test:unit": "tape tests/**/*.test.js | faucet",
"test:smoke": "tape tests/*.smoketest.js | faucet"
},
Expand All @@ -26,6 +26,11 @@
"iojs": ">=2.5.0",
"node": ">=4.0.0"
},
"standard": {
"ignore": [
"static/"
]
},
"dependencies": {
"autoprefixer-stylus": "0.8.1",
"changelog-url": "1.0.2",
Expand Down Expand Up @@ -62,7 +67,7 @@
"nock": "^2.17.0",
"pre-commit": "^1.1.2",
"proxyquire": "^1.7.3",
"standard": "^5.3.1",
"standard": "^6.0.8",
"tape": "^4.2.2"
}
}
2 changes: 1 addition & 1 deletion scripts/release-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function fetchVersionPolicy (version) {
// matches the policy for a given version (Stable, LTS etc) in the changelog
// ## 2015-10-07, Version 4.2.0 'Argon' (LTS), @jasnell
// 2015-12-04, Version 0.12.9 (LTS), @rvagg
const rxPolicy = new RegExp(`^(## )?\\d{4}-\\d{2}-\\d{2}, Version [^(].*\\(([^\\)]+)\\)`)
const rxPolicy = new RegExp('^(## )?\\d{4}-\\d{2}-\\d{2}, Version [^(].*\\(([^\\)]+)\\)')

return fetchChangelog(version)
.then((section) => {
Expand Down