Skip to content

Commit

Permalink
Merge pull request #138 from steelbrain/steelbrain/maintenance
Browse files Browse the repository at this point in the history
Maintenance
  • Loading branch information
steelbrain authored Jul 9, 2016
2 parents f9fb44d + 55abad6 commit 7e9bbbc
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 80 deletions.
1 change: 0 additions & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[ignore]
.*/lib/*
.*/node_modules/*

[include]

Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules
/spec
/src
.flowconfig
24 changes: 13 additions & 11 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
dependencies:
pre:
# Force updating wget due to the current containers being too out of date
- sudo apt-get update
- sudo apt-get install wget
override:
- wget -O atom-amd64.deb https://atom.io/download/deb
# - sudo apt-get update # Cut out until wget is fixed on the containers
- curl -L https://atom.io/download/deb -o atom-amd64.deb
- sudo dpkg --install atom-amd64.deb || true
- sudo apt-get update
- sudo apt-get -f install
- apm install
- node --version
- npm --version
- atom --version
- rm -rf node_modules; npm install
- npm run compile

test:
override:
- atom -v
- apm -v
- ./node_modules/.bin/eslint ./
- apm test
- npm run lint
- npm test

machine:
node:
version: 6.3.0
40 changes: 6 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "lib/index.js",
"scripts": {
"test": "apm test",
"lint": "eslint .",
"watch": "ucompiler watch",
"compile": "ucompiler go"
},
Expand All @@ -29,44 +30,15 @@
"tmp": "~0.0.28"
},
"devDependencies": {
"eslint": "^2.4.0",
"babel-eslint": "^6.0.0-beta.6",
"eslint-config-airbnb": "^6.0.2",
"babel-preset-steelbrain": "^2.0.1",
"eslint-config-steelbrain": "^1.0.1",
"jasmine-fix": "^1.0.0",
"ucompiler": "^3.0.1",
"ucompiler-plugin-babel": "^3.0.0",
"ucompiler-plugin-newline": "^3.0.0",
"babel-preset-steelbrain": "^2.0.1"
"ucompiler-plugin-newline": "^3.0.0"
},
"eslintConfig": {
"rules": {
"no-param-reassign": [
2,
{
"props": false
}
],
"func-names": 0,
"comma-dangle": 0,
"no-extra-semi": 1,
"no-loop-func": 0,
"semi": [
2,
"never"
],
"prefer-arrow-callback": 0,
"max-len": [
2,
200
]
},
"extends": "airbnb/base",
"parser": "babel-eslint",
"globals": {
"atom": "true"
},
"env": {
"es6": true,
"node": true
}
"extends": "steelbrain"
}
}
11 changes: 6 additions & 5 deletions spec/helper-spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use babel'

import 'jasmine-fix'
import * as fs from 'fs'
import * as path from 'path'
import { waitsForAsync, waitsForAsyncRejection } from './spec-helpers'
Expand Down Expand Up @@ -104,8 +105,8 @@ describe('linter helpers', function () {
type: 'type',
text: 'message',
filePath: null,
range: [[0, 0], [0, 0]]
}
range: [[0, 0], [0, 0]],
},
]
let results = helpers.parse(input, regex, { flags: 'i' })
expect(results).toEqual(output)
Expand All @@ -117,8 +118,8 @@ describe('linter helpers', function () {
type: 'type',
text: 'message',
filePath: null,
range: [[0, 0], [0, 0]]
}
range: [[0, 0], [0, 0]],
},
]
results = helpers.parse(input, regex, { flags: 'gi' })
expect(results).toEqual(output)
Expand Down Expand Up @@ -228,7 +229,7 @@ describe('linter helpers', function () {
waitsForAsync(async () =>
await helpers.tempFiles([
{ name: 'foo.js', contents: 'Foo!' },
{ name: 'bar.js', contents: 'Bar!' }
{ name: 'bar.js', contents: 'Bar!' },
], filepaths => {
expect(filepaths[0].indexOf('atom-linter_')).not.toBe(-1)
expect(path.basename(filepaths[0])).toBe('foo.js')
Expand Down
14 changes: 0 additions & 14 deletions spec/spec-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,3 @@ export function waitsForAsyncRejection(asynCallback, errorMessage) {
})
})
}

// Jasmine 1.3.x has no sane way of resetting to native clocks, and since we're
// gonna test promises and such, we're gonna need it
function resetClock() {
for (const key in jasmine.Clock.real) {
if (jasmine.Clock.hasOwnProperty('real')) {
window[key] = jasmine.Clock.real[key]
}
}
}

beforeEach(function () {
resetClock()
})
10 changes: 1 addition & 9 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ import type { TempDirectory } from './types'

export const writeFile = promisify(FS.writeFile)
export const unlinkFile = promisify(FS.unlink)
export const assign = Object.assign || function (target, source) {
for (const key in source) {
if (source.hasOwnProperty(key)) {
target[key] = source[key]
}
}
return target
}

function escapeRegexp(string: string): string {
// Shamelessly stolen from https://github.com/atom/underscore-plus/blob/130913c179fe1d718a14034f4818adaf8da4db12/src/underscore-plus.coffee#L138
Expand All @@ -27,7 +19,7 @@ function escapeRegexp(string: string): string {
export function getWordRegexp(textEditor: TextEditor, bufferPosition: Range) {
const scopeDescriptor = textEditor.scopeDescriptorForBufferPosition(bufferPosition)
const nonWordCharacters = escapeRegexp(atom.config.get('editor.nonWordCharacters', {
scope: scopeDescriptor
scope: scopeDescriptor,
}))
return new RegExp(`^[\t ]*$|[^\\s${nonWordCharacters}]+`)
}
Expand Down
13 changes: 7 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

import * as Path from 'path'
import * as FS from 'fs'
import * as Helpers from './helpers'
import { exec, execNode } from 'sb-exec'
import type { TextEditor, Range } from 'atom'
import * as Helpers from './helpers'
import type { TempFiles } from './types'
import { exec, execNode } from 'sb-exec'

let NamedRegexp = null
export const FindCache = new Map()
Expand Down Expand Up @@ -48,7 +48,7 @@ export function rangeFromLineNumber(textEditor: TextEditor, line: ?number, colum

return [
[lineNumber, colStart],
[lineNumber, colEnd]
[lineNumber, colEnd],
]
}

Expand Down Expand Up @@ -194,7 +194,7 @@ export function tempFile<T>(

return tempFiles([{
name: fileName,
contents: fileContents
contents: fileContents,
}], function (results) {
return callback(results[0])
})
Expand All @@ -210,10 +210,11 @@ export function parse(data, regex, opts = {}) {
}

if (NamedRegexp === null) {
/* eslint-disable global-require */
NamedRegexp = require('named-js-regexp')
}

const options = Helpers.assign({ flags: '' }, opts)
const options = Object.assign({ flags: '' }, opts)
if (options.flags.indexOf('g') === -1) {
options.flags += 'g'
}
Expand All @@ -240,7 +241,7 @@ export function parse(data, regex, opts = {}) {
range: [
[lineStart > 0 ? lineStart - 1 : 0, colStart > 0 ? colStart - 1 : 0],
[lineEnd > 0 ? lineEnd - 1 : 0, colEnd > 0 ? colEnd - 1 : 0],
]
],
})

rawMatch = compiledRegexp.exec(data)
Expand Down

0 comments on commit 7e9bbbc

Please sign in to comment.