diff --git a/coffeelint.json b/coffeelint.json new file mode 100644 index 0000000..49595dd --- /dev/null +++ b/coffeelint.json @@ -0,0 +1,5 @@ +{ + "max_line_length": { + "level": "ignore" + } +} diff --git a/package.json b/package.json index 1add334..db68087 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,10 @@ "description": "Linter plugin for pycodestyle", "repository": "https://github.com/AtomLinter/linter-pycodestyle", "license": "MIT", + "scripts": { + "test": "apm test", + "lint": "coffeelint ." + }, "engines": { "atom": ">0.50.0" }, @@ -12,6 +16,10 @@ "atom-linter": "^8.0.0", "atom-package-deps": "^4.0.1" }, + "devDependencies": { + "jasmine-fix": "^1.0.1", + "coffeelint": "^1.9.7" + }, "package-deps": [ "linter" ], diff --git a/spec/fixtures/bad.py b/spec/fixtures/bad.py new file mode 100644 index 0000000..36d209a --- /dev/null +++ b/spec/fixtures/bad.py @@ -0,0 +1 @@ +import os, path diff --git a/spec/fixtures/empty.py b/spec/fixtures/empty.py new file mode 100644 index 0000000..e69de29 diff --git a/spec/fixtures/good.py b/spec/fixtures/good.py new file mode 100644 index 0000000..d6f7beb --- /dev/null +++ b/spec/fixtures/good.py @@ -0,0 +1 @@ +"""Simple test file.""" diff --git a/spec/linter-pycodestyle-spec.js b/spec/linter-pycodestyle-spec.js new file mode 100644 index 0000000..53f3fc9 --- /dev/null +++ b/spec/linter-pycodestyle-spec.js @@ -0,0 +1,56 @@ +'use babel'; + +import { join } from 'path'; +// eslint-disable-next-line no-unused-vars +import { it, fit, wait, beforeEach, afterEach } from 'jasmine-fix'; + +const fixturePath = join(__dirname, 'fixtures'); +const goodPath = join(fixturePath, 'good.py'); +const badPath = join(fixturePath, 'bad.py'); +const emptyPath = join(fixturePath, 'empty.py'); + +describe('The pycodestyle provider for Linter', () => { + const lint = require('../lib/main.coffee').provideLinter().lint; + + beforeEach(async () => { + // Info about this beforeEach() implementation: + // https://github.com/AtomLinter/Meta/issues/15 + const activationPromise = atom.packages.activatePackage('linter-pycodestyle'); + + await atom.packages.activatePackage('language-python'); + + atom.packages.triggerDeferredActivationHooks(); + await activationPromise; + }); + + it('should be in the packages list', () => + expect(atom.packages.isPackageLoaded('linter-pycodestyle')).toBe(true), + ); + + it('should be an active package', () => + expect(atom.packages.isPackageActive('linter-pycodestyle')).toBe(true), + ); + + describe('checks bad.py and', () => { + let editor = null; + beforeEach(async () => { + editor = await atom.workspace.open(badPath); + }); + + it('verifies that message', async () => { + const messages = await lint(editor); + expect(messages[0].type).toBe('Warning'); + expect(messages[0].html).not.toBeDefined(); + expect(messages[0].text).toBe(' E401 multiple imports on one line'); + expect(messages[0].filePath).toBe(badPath); + expect(messages[0].range).toEqual([[0, 9], [0, 10]]); + }); + }); + + it('finds nothing wrong with a valid file', async () => { + const editor = await atom.workspace.open(goodPath); + const messages = await lint(editor); + expect(messages.length).toBe(0); + }); + +});