From 0f1d5c7473bb08f17d6b35613f39851af93f1fef Mon Sep 17 00:00:00 2001 From: Landon Abney Date: Mon, 26 Sep 2016 15:57:34 -0700 Subject: [PATCH 1/2] Add basic specs Add some specs testing that the linter is working. Also brings in and configures ESLint to lint the specs. --- package.json | 31 ++++++++++++++++++--- spec/.eslintrc.js | 6 +++++ spec/fixtures/invalid/invalid.ts | 2 ++ spec/fixtures/invalid/tsconfig.json | 7 +++++ spec/fixtures/invalid/tslint.json | 5 ++++ spec/fixtures/valid/tsconfig.json | 7 +++++ spec/fixtures/valid/tslint.json | 5 ++++ spec/fixtures/valid/valid.ts | 2 ++ spec/linter-tslint-spec.js | 42 +++++++++++++++++++++++++++++ 9 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 spec/.eslintrc.js create mode 100644 spec/fixtures/invalid/invalid.ts create mode 100644 spec/fixtures/invalid/tsconfig.json create mode 100644 spec/fixtures/invalid/tslint.json create mode 100644 spec/fixtures/valid/tsconfig.json create mode 100644 spec/fixtures/valid/tslint.json create mode 100644 spec/fixtures/valid/valid.ts create mode 100644 spec/linter-tslint-spec.js diff --git a/package.json b/package.json index 9349acdb..06a167bc 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "url": "https://github.com/AtomLinter/linter-tslint.git" }, "scripts": { - "test": "npm run lint", - "lint": "coffeelint ./lib" + "test": "apm test", + "lint": "coffeelint lib && eslint ." }, "license": "MIT", "engines": { @@ -42,6 +42,31 @@ } }, "devDependencies": { - "coffeelint": "1.15.7" + "coffeelint": "1.15.7", + "eslint": "^3.6.0", + "eslint-config-airbnb-base": "^8.0.0", + "eslint-plugin-import": "^1.16.0" + }, + "eslintConfig": { + "extends": "airbnb-base", + "rules": { + "global-require": "off", + "import/no-unresolved": [ + "error", + { + "ignore": [ + "atom" + ] + } + ] + }, + "env": { + "es6": true, + "browser": true, + "node": true + }, + "globals": { + "atom": true + } } } diff --git a/spec/.eslintrc.js b/spec/.eslintrc.js new file mode 100644 index 00000000..d343254a --- /dev/null +++ b/spec/.eslintrc.js @@ -0,0 +1,6 @@ +module.exports = { + env: { + jasmine: true, + atomtest: true + } +}; diff --git a/spec/fixtures/invalid/invalid.ts b/spec/fixtures/invalid/invalid.ts new file mode 100644 index 00000000..6b9257e6 --- /dev/null +++ b/spec/fixtures/invalid/invalid.ts @@ -0,0 +1,2 @@ +const foo = 42 +export default foo; diff --git a/spec/fixtures/invalid/tsconfig.json b/spec/fixtures/invalid/tsconfig.json new file mode 100644 index 00000000..e88865a6 --- /dev/null +++ b/spec/fixtures/invalid/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compileOnSave": false, + "buildOnSave": false, + "atom": { + "rewriteTsconfig": false + } +} diff --git a/spec/fixtures/invalid/tslint.json b/spec/fixtures/invalid/tslint.json new file mode 100644 index 00000000..7a7a8e7d --- /dev/null +++ b/spec/fixtures/invalid/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "semicolon": true + } +} diff --git a/spec/fixtures/valid/tsconfig.json b/spec/fixtures/valid/tsconfig.json new file mode 100644 index 00000000..e88865a6 --- /dev/null +++ b/spec/fixtures/valid/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compileOnSave": false, + "buildOnSave": false, + "atom": { + "rewriteTsconfig": false + } +} diff --git a/spec/fixtures/valid/tslint.json b/spec/fixtures/valid/tslint.json new file mode 100644 index 00000000..7a7a8e7d --- /dev/null +++ b/spec/fixtures/valid/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "semicolon": true + } +} diff --git a/spec/fixtures/valid/valid.ts b/spec/fixtures/valid/valid.ts new file mode 100644 index 00000000..129e7f10 --- /dev/null +++ b/spec/fixtures/valid/valid.ts @@ -0,0 +1,2 @@ +const foo = 42; +export default foo; diff --git a/spec/linter-tslint-spec.js b/spec/linter-tslint-spec.js new file mode 100644 index 00000000..ed4d328c --- /dev/null +++ b/spec/linter-tslint-spec.js @@ -0,0 +1,42 @@ +'use babel'; + +import * as path from 'path'; + +const validPath = path.join(__dirname, 'fixtures', 'valid', 'valid.ts'); +const invalidPath = path.join(__dirname, 'fixtures', 'invalid', 'invalid.ts'); + +describe('The TSLint provider for Linter', () => { + const lint = require('../lib/init.coffee').provideLinter().lint; + + beforeEach(() => { + atom.workspace.destroyActivePaneItem(); + + waitsForPromise(() => + Promise.all([ + atom.packages.activatePackage('linter-tslint'), + ]) + ); + }); + + it('finds nothing wrong with a valid file', () => { + waitsForPromise(() => + atom.workspace.open(validPath).then(editor => lint(editor)).then((messages) => { + expect(messages.length).toBe(0); + }) + ); + }); + + it('handles messages from TSLint', () => { + const expectedMsg = 'semicolon - Missing semicolon'; + waitsForPromise(() => + atom.workspace.open(invalidPath).then(editor => lint(editor)).then((messages) => { + expect(messages.length).toBe(1); + expect(messages[0].type).toBe('Warning'); + expect(messages[0].html).not.toBeDefined(); + expect(messages[0].text).toBe(expectedMsg); + expect(messages[0].filePath).toBe(invalidPath); + expect(messages[0].range).toEqual([[0, 14], [0, 14]]); + }) + ); + }); +}); From 4d70ea0338cd876549aebe3e5493983c378f81a3 Mon Sep 17 00:00:00 2001 From: Landon Abney Date: Mon, 26 Sep 2016 16:05:42 -0700 Subject: [PATCH 2/2] Fix CI configuration I'm not sure what the CI was testing before... but it had nothing to do with this package. --- .travis.yml | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d5ffc9c..27c2805f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,41 @@ -language: node_js -node_js: - - "4.1" -env: - - CXX=g++-4.8 +### Project specific config ### +language: generic + +matrix: + include: + - os: linux + env: ATOM_CHANNEL=stable + + - os: linux + env: ATOM_CHANNEL=beta + + - os: osx + env: ATOM_CHANNEL=stable + +### Generic setup follows ### +script: + - curl -s -O https://raw.githubusercontent.com/atom/ci/master/build-package.sh + - chmod u+x build-package.sh + - ./build-package.sh + +notifications: + email: + on_success: never + on_failure: change + +branches: + only: + - master + +git: + depth: 10 + +sudo: false + addons: apt: - sources: - - ubuntu-toolchain-r-test packages: - - g++-4.8 + - build-essential + - git + - libgnome-keyring-dev + - fakeroot