Skip to content

Commit

Permalink
Add coffee lint
Browse files Browse the repository at this point in the history
  • Loading branch information
yulii committed Dec 7, 2019
1 parent 6b80fdb commit 0837c77
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 37 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
- run:
name: Run test
command: yarn test
- run:
name: Run lint
command: yarn lint
- run:
name: Measure coverage
command: |
Expand Down
133 changes: 133 additions & 0 deletions coffeelint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"arrow_spacing": {
"level": "ignore"
},
"braces_spacing": {
"level": "error",
"spaces": 1,
"empty_object_spaces": 0
},
"camel_case_classes": {
"level": "error"
},
"coffeescript_error": {
"level": "error"
},
"colon_assignment_spacing": {
"level": "ignore",
"spacing": {
"left": 0,
"right": 0
}
},
"cyclomatic_complexity": {
"level": "error",
"value": 10
},
"duplicate_key": {
"level": "error"
},
"empty_constructor_needs_parens": {
"level": "ignore"
},
"ensure_comprehensions": {
"level": "warn"
},
"eol_last": {
"level": "ignore"
},
"indentation": {
"value": 2,
"level": "error"
},
"line_endings": {
"level": "ignore",
"value": "unix"
},
"max_line_length": {
"level": "ignore"
},
"missing_fat_arrows": {
"level": "ignore",
"is_strict": false
},
"newlines_after_classes": {
"value": 3,
"level": "ignore"
},
"no_backticks": {
"level": "error"
},
"no_debugger": {
"level": "warn",
"console": false
},
"no_empty_functions": {
"level": "ignore"
},
"no_empty_param_list": {
"level": "ignore"
},
"no_implicit_braces": {
"level": "ignore",
"strict": true
},
"no_implicit_parens": {
"level": "ignore",
"strict": true
},
"no_interpolation_in_single_quotes": {
"level": "ignore"
},
"no_nested_string_interpolation": {
"level": "warn"
},
"no_plusplus": {
"level": "ignore"
},
"no_private_function_fat_arrows": {
"level": "warn"
},
"no_stand_alone_at": {
"level": "ignore"
},
"no_tabs": {
"level": "error"
},
"no_this": {
"level": "ignore"
},
"no_throwing_strings": {
"level": "error"
},
"no_trailing_semicolons": {
"level": "error"
},
"no_trailing_whitespace": {
"level": "error",
"allowed_in_comments": false,
"allowed_in_empty_lines": true
},
"no_unnecessary_double_quotes": {
"level": "ignore"
},
"no_unnecessary_fat_arrows": {
"level": "warn"
},
"non_empty_constructor_needs_parens": {
"level": "ignore"
},
"prefer_english_operator": {
"level": "ignore",
"doubleNotLevel": "ignore"
},
"space_operators": {
"level": "ignore"
},
"spacing_after_comma": {
"level": "ignore"
},
"transform_messes_up_line_numbers": {
"level": "warn"
}
}
5 changes: 1 addition & 4 deletions lib/alpha_vantage.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ class AlphaVantage
return _endpoint

execute: (robot, callback) ->
queryString = QueryString.build
apiKey: @token
function: @function
symbol: @symbol
queryString = QueryString.build(apiKey: @token, function: @function, symbol: @symbol)

robot.http("#{@endpoint()}?#{queryString}")
.header('Content-Type', 'application/json')
Expand Down
2 changes: 1 addition & 1 deletion lib/alpha_vantage/time_series_daily.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class AlphaVantageTimeSeriesDaily

_initialize = ->
_timezone = _meta['5. Time Zone']
_ts_keys = Object.keys(_data).map((x) => moment.tz(x, _timezone).valueOf()).sort((a, b) => return (a < b ? 1 : -1))
_ts_keys = Object.keys(_data).map((x) -> moment.tz(x, _timezone).valueOf()).sort((a, b) -> return (a < b ? 1 : -1))

_key = (timestamp) ->
return moment(timestamp).tz(_timezone).format('YYYY-MM-DD')
Expand Down
5 changes: 1 addition & 4 deletions lib/circleci.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ class CircleCI
return @

execute: (robot) ->
params = JSON.stringify
build_parameters:
CIRCLE_JOB: @job
JOB_USER: robot.name
params = JSON.stringify(build_parameters: { CIRCLE_JOB: @job, JOB_USER: robot.name })

robot.http("#{@endpoint()}?circle-token=#{@token}")
.header('Content-Type', 'application/json')
Expand Down
2 changes: 1 addition & 1 deletion lib/query_string.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class QueryString

@build: (params) ->
return Object.keys(params).map((k) -> encodeURIComponent(k) + '=' + encodeURIComponent(params[k])).join('&');
return Object.keys(params).map((k) -> encodeURIComponent(k) + '=' + encodeURIComponent(params[k])).join('&')

module.exports = QueryString
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"devDependencies": {
"chai": "latest",
"coffee-coverage": "latest",
"coffeelint": "latest",
"coffeescript": "latest",
"coveralls": "latest",
"hubot-mock-adapter": "latest",
Expand All @@ -39,6 +40,7 @@
},
"scripts": {
"test": "mocha \"test/**/*.{js,coffee}\"",
"lint": "coffeelint lib/ scripts/ test/",
"coverage": "istanbul report text-summary lcov"
}
}
30 changes: 4 additions & 26 deletions test/lib/circleci.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ describe 'CircleCI', ->
delete process.env.CIRCLE_TOKEN_PROJECT_REPOSITORY_NAME

it 'returns environment variable name', () ->
ci = new CircleCI(
owner: 'yulii'
job: 'test'
project: 'project.repository-name'
)

ci = new CircleCI(owner: 'yulii', job: 'test', project: 'project.repository-name')
expect(ci.tokenEnvName()).to.equal('CIRCLE_TOKEN_PROJECT_REPOSITORY_NAME')

describe '#tokenEnvValue', ->
Expand All @@ -58,33 +53,16 @@ describe 'CircleCI', ->
delete process.env.CIRCLE_TOKEN_PROJECT_REPOSITORY_NAME

it 'returns environment variable', () ->
ci = new CircleCI(
owner: 'yulii'
job: 'test'
project: 'project.repository-name'
)

ci = new CircleCI(owner: 'yulii', job: 'test', project: 'project.repository-name')
expect(ci.tokenEnvValue()).to.equal('circle-project-token')

describe '#endpoint', ->
it 'returns endpoint url in CircleCI API', () ->
ci = new CircleCI(
owner: 'yulii'
job: 'test'
project: 'mocha'
token: 'circle-token'
)

ci = new CircleCI(owner: 'yulii', job: 'test', project: 'mocha', token: 'circle-token')
expect(ci.endpoint()).to.equal('https://circleci.com/api/v1.1/project/github/yulii/mocha/tree/master')

describe '#notify', ->
it 'sets `destination` property', () ->
ci = new CircleCI(
owner: 'yulii'
job: 'test'
project: 'mocha'
token: 'circle-token'
).notify('address')

ci = new CircleCI(owner: 'yulii', job: 'test', project: 'mocha', token: 'circle-token').notify('address')
expect(ci).to.be.an.instanceof(CircleCI)
expect(ci).to.have.property('destination', 'address')
41 changes: 40 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,24 @@ coffee-coverage@latest:
minimatch "^3.0.2"
pkginfo ">=0.2.3"

coffeelint@latest:
version "2.1.0"
resolved "https://registry.yarnpkg.com/coffeelint/-/coffeelint-2.1.0.tgz#af65df3634e999d9ac01480736c36d3cd2f5dad8"
integrity sha1-r2XfNjTpmdmsAUgHNsNtPNL12tg=
dependencies:
coffeescript "^2.1.0"
glob "^7.0.6"
ignore "^3.0.9"
optimist "^0.6.1"
resolve "^0.6.3"
strip-json-comments "^1.0.2"

coffeescript@1.6.3:
version "1.6.3"
resolved "https://registry.yarnpkg.com/coffeescript/-/coffeescript-1.6.3.tgz#41749750c621a6553c7c03818a5384bb24c30541"
integrity sha1-QXSXUMYhplU8fAOBilOEuyTDBUE=

coffeescript@^2.0.2, coffeescript@latest:
coffeescript@^2.0.2, coffeescript@^2.1.0, coffeescript@latest:
version "2.4.1"
resolved "https://registry.yarnpkg.com/coffeescript/-/coffeescript-2.4.1.tgz#815fd337df0a34d49e74a98a6ebea9c3e7930f70"
integrity sha512-34GV1aHrsMpTaO3KfMJL40ZNuvKDR/g98THHnE9bQj8HjMaZvSrLik99WWqyMhRtbe8V5hpx5iLgdcSvM/S2wg==
Expand Down Expand Up @@ -728,6 +740,18 @@ glob@^5.0.15:
once "^1.3.0"
path-is-absolute "^1.0.0"

glob@^7.0.6:
version "7.1.6"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"

growl@1.10.5:
version "1.10.5"
resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e"
Expand Down Expand Up @@ -875,6 +899,11 @@ iconv-lite@0.4.24:
dependencies:
safer-buffer ">= 2.1.2 < 3"

ignore@^3.0.9:
version "3.3.10"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043"
integrity sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==

inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
Expand Down Expand Up @@ -1440,6 +1469,11 @@ resolve@1.1.x:
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
integrity sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=

resolve@^0.6.3:
version "0.6.3"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-0.6.3.tgz#dd957982e7e736debdf53b58a4dd91754575dd46"
integrity sha1-3ZV5gufnNt699TtYpN2RdUV13UY=

retry@^0.9.0:
version "0.9.0"
resolved "https://registry.yarnpkg.com/retry/-/retry-0.9.0.tgz#6f697e50a0e4ddc8c8f7fb547a9b60dead43678d"
Expand Down Expand Up @@ -1610,6 +1644,11 @@ strip-json-comments@2.0.1:
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo=

strip-json-comments@^1.0.2:
version "1.0.4"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91"
integrity sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=

supports-color@6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.0.0.tgz#76cfe742cf1f41bb9b1c29ad03068c05b4c0e40a"
Expand Down

0 comments on commit 0837c77

Please sign in to comment.