Merge pull request #171 from resin-io/170-linting

Linting
This commit is contained in:
Kostas Lekkas 2016-06-17 17:56:19 +03:00 committed by GitHub
commit c53f96edcc
9 changed files with 29 additions and 158 deletions

View File

@ -1,127 +0,0 @@
{
"coffeescript_error": {
"level": "error"
},
"arrow_spacing": {
"name": "arrow_spacing",
"level": "error"
},
"no_tabs": {
"name": "no_tabs",
"level": "ignore"
},
"no_trailing_whitespace": {
"name": "no_trailing_whitespace",
"level": "error",
"allowed_in_comments": false,
"allowed_in_empty_lines": false
},
"max_line_length": {
"name": "max_line_length",
"value": 120,
"level": "error",
"limitComments": true
},
"line_endings": {
"name": "line_endings",
"level": "ignore",
"value": "unix"
},
"no_trailing_semicolons": {
"name": "no_trailing_semicolons",
"level": "error"
},
"indentation": {
"name": "indentation",
"value": 1,
"level": "error"
},
"camel_case_classes": {
"name": "camel_case_classes",
"level": "error"
},
"colon_assignment_spacing": {
"name": "colon_assignment_spacing",
"level": "error",
"spacing": {
"left": 0,
"right": 1
}
},
"no_implicit_braces": {
"name": "no_implicit_braces",
"level": "ignore",
"strict": false
},
"no_plusplus": {
"name": "no_plusplus",
"level": "ignore"
},
"no_throwing_strings": {
"name": "no_throwing_strings",
"level": "error"
},
"no_backticks": {
"name": "no_backticks",
"level": "warn"
},
"no_implicit_parens": {
"name": "no_implicit_parens",
"strict": false,
"level": "ignore"
},
"no_empty_param_list": {
"name": "no_empty_param_list",
"level": "error"
},
"no_stand_alone_at": {
"name": "no_stand_alone_at",
"level": "ignore"
},
"space_operators": {
"name": "space_operators",
"level": "error"
},
"duplicate_key": {
"name": "duplicate_key",
"level": "error"
},
"empty_constructor_needs_parens": {
"name": "empty_constructor_needs_parens",
"level": "ignore"
},
"cyclomatic_complexity": {
"name": "cyclomatic_complexity",
"value": 10,
"level": "ignore"
},
"newlines_after_classes": {
"name": "newlines_after_classes",
"value": 3,
"level": "ignore"
},
"no_unnecessary_fat_arrows": {
"name": "no_unnecessary_fat_arrows",
"level": "error"
},
"missing_fat_arrows": {
"name": "missing_fat_arrows",
"level": "ignore"
},
"non_empty_constructor_needs_parens": {
"name": "non_empty_constructor_needs_parens",
"level": "ignore"
},
"no_unnecessary_double_quotes": {
"name": "no_unnecessary_double_quotes",
"level": "error"
},
"no_debugger": {
"name": "no_debugger",
"level": "warn"
},
"no_interpolation_in_single_quotes": {
"name": "no_interpolation_in_single_quotes",
"level": "error"
}
}

View File

@ -3,7 +3,8 @@
"version": "1.11.3",
"scripts": {
"postinstall": "sh postinstall.sh",
"start": "./entry.sh"
"start": "./entry.sh",
"lint": "resin-lint src/"
},
"dependencies": {
"JSONStream": "^1.1.2",
@ -33,5 +34,8 @@
},
"engines": {
"node": "0.10.22"
},
"devDependencies": {
"resin-lint": "^1.3.1"
}
}

View File

@ -1,5 +1,4 @@
Promise = require 'bluebird'
fs = Promise.promisifyAll require 'fs'
utils = require './utils'
knex = require './db'
express = require 'express'

View File

@ -100,7 +100,7 @@ logSpecialAction = (action, value, success) ->
msg = "Applied config variable #{action} = #{value}"
else
msg = "Applying config variable #{action} = #{value}"
logSystemMessage(msg, {}, "Apply special action #{success ? "success" : "in progress"}")
logSystemMessage(msg, {}, "Apply special action #{if success then "success" else "in progress"}")
application = {}

View File

@ -1,11 +1,9 @@
Promise = require 'bluebird'
_ = require 'lodash'
knex = require './db'
utils = require './utils'
deviceRegister = require 'resin-register-device'
{ resinApi } = require './request'
fs = Promise.promisifyAll(require('fs'))
EventEmitter = require('events').EventEmitter
config = require './config'
configPath = '/boot/config.json'
appsPath = '/boot/apps.json'

View File

@ -17,7 +17,7 @@ checkString = (s) ->
dockerRoot = checkString(process.env.DOCKER_ROOT) ? '/mnt/root/var/lib/rce'
# Defaults needed for both gosuper and node supervisor are declared in entry.sh
module.exports = config =
module.exports =
apiEndpoint: checkString(process.env.API_ENDPOINT) ? 'https://api.resin.io'
apiTimeout: checkInt(process.env.API_TIMEOUT) ? 15 * 60 * 1000
listenPort: checkInt(process.env.LISTEN_PORT) ? 80
@ -48,4 +48,4 @@ module.exports = config =
'RESIN_SUPERVISOR_API_KEY'
'RESIN_API_KEY'
]
dataPath: checkString(process.env.RESIN_DATA_PATH) ? "/resin-data"
dataPath: checkString(process.env.RESIN_DATA_PATH) ? '/resin-data'

View File

@ -35,10 +35,10 @@ exports.getID = do ->
throw new Error('Could not find this device?!')
return devices[0].id
exports.reboot = rebootDevice = ->
exports.reboot = ->
request.postAsync(config.gosuperAddress + '/v1/reboot')
exports.hostConfigEnvVarPrefix = hostConfigEnvVarPrefix = 'RESIN_HOST_'
exports.hostConfigEnvVarPrefix = 'RESIN_HOST_'
bootConfigEnvVarPrefix = 'RESIN_HOST_CONFIG_'
bootBlockDevice = '/dev/mmcblk0p1'
bootMountPoint = '/mnt/root/boot'
@ -80,14 +80,14 @@ setLogToDisplay = (env, logMessage) ->
request.postAsync(config.gosuperAddress + '/v1/set-log-to-display', { json: true, body: Enable: enable })
.spread (response, body) ->
if response.statusCode != 200
logMessage("Error setting log to display: #{body.Error}, Status:, #{response.statusCode}", {error: body.Error}, "Set log to display error")
logMessage("Error setting log to display: #{body.Error}, Status:, #{response.statusCode}", { error: body.Error }, 'Set log to display error')
return false
else
if body.Data == true
logMessage("#{if enable then "Enabled" else "Disabled"} logs to display")
logMessage("#{if enable then 'Enabled' else 'Disabled'} logs to display")
return body.Data
.catch (err) ->
logMessage("Error setting log to display: #{err}", {error: err}, "Set log to display error")
logMessage("Error setting log to display: #{err}", { error: err }, 'Set log to display error')
return false
else
return Promise.resolve(false)
@ -118,7 +118,7 @@ setBootConfig = (env, logMessage) ->
configFromApp[key] != configFromFS[key]
throw new Error('Nothing to change') if _.isEmpty(toBeChanged) and _.isEmpty(toBeAdded)
logMessage("Applying boot config: #{JSON.stringify(configFromApp)}", {}, "Apply boot config in progress")
logMessage("Applying boot config: #{JSON.stringify(configFromApp)}", {}, 'Apply boot config in progress')
# We add the keys to be added first so they are out of any filters
outputConfig = _.map toBeAdded, (key) -> "#{key}=#{configFromApp[key]}"
outputConfig = outputConfig.concat _.map configPositions, (key, index) ->
@ -137,10 +137,10 @@ setBootConfig = (env, logMessage) ->
.then ->
execAsync('sync')
.then ->
logMessage("Applied boot config: #{JSON.stringify(configFromApp)}", {}, "Apply boot config success")
logMessage("Applied boot config: #{JSON.stringify(configFromApp)}", {}, 'Apply boot config success')
return true
.catch (err) ->
logMessage("Error setting boot config: #{err}", {error: err}, "Apply boot config error")
logMessage("Error setting boot config: #{err}", { error: err }, 'Apply boot config error')
throw err
.catch (err) ->
console.log('Will not set boot config: ', err)
@ -221,7 +221,7 @@ do ->
exports.getOSVersion = ->
fs.readFileAsync(config.hostOsVersionPath)
.then (releaseData) ->
lines = (new String(releaseData)).split("\n")
lines = (new String(releaseData)).split('\n')
releaseItems = {}
for line in lines
[ key, val ] = line.split('=')
@ -229,5 +229,5 @@ exports.getOSVersion = ->
# Remove enclosing quotes: http://stackoverflow.com/a/19156197/2549019
return releaseItems['PRETTY_NAME'].replace(/^"(.+(?="$))"$/, '$1')
.catch (err) ->
console.log("Could not get OS Version: ", err, err.stack)
console.log('Could not get OS Version: ', err, err.stack)
return undefined

View File

@ -7,7 +7,6 @@ config = require './config'
_ = require 'lodash'
knex = require './db'
{ request } = require './request'
fs = Promise.promisifyAll require 'fs'
Lock = require 'rwlock'
docker = Promise.promisifyAll(new Docker(socketPath: config.dockerSocket))
@ -183,7 +182,7 @@ do ->
_.omit(query, 'apikey')
exports.createImage = (req, res) ->
{ registry, repo, tag, fromImage, fromSrc } = req.query
{ registry, repo, tag, fromImage } = req.query
if fromImage?
repoTag = fromImage
repoTag += ':' + tag if tag?

View File

@ -11,8 +11,6 @@ randomHexString = require './lib/random-hex-string'
request = Promise.promisifyAll require 'request'
logger = require './lib/logger'
utils = exports
# Parses package.json and returns resin-supervisor's version
version = require('../package.json').version
tagExtra = process.env.SUPERVISOR_TAG_EXTRA