Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

V2 linter API support #39

Merged
merged 6 commits into from
Feb 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -20,6 +20,9 @@ defaults: &defaults
- run:
name: Install flint
command: go get -u github.com/pengwynn/flint
- run:
name: Flint version
command: flint --version
- run:
name: Create VFB for Atom to run in
command: /usr/local/bin/xvfb_start
@@ -29,12 +32,6 @@ defaults: &defaults
- run:
name: APM version
command: ${APM_SCRIPT_PATH} --version
- run:
name: Flint version
command: flint --version
- run:
name: Cleaning package
command: ${APM_SCRIPT_PATH} clean
- run:
name: Package APM package dependencies
command: |
@@ -46,14 +43,17 @@ defaults: &defaults
- run:
name: Package dependencies
command: ${APM_SCRIPT_PATH} install
- run:
name: Cleaning package
command: ${APM_SCRIPT_PATH} clean
- run:
name: Package specs
command: ${ATOM_SCRIPT_PATH} --test spec
# Cache node_modules
- save_cache:
paths:
- node_modules
key: v2-dependencies-{{ checksum "package.json" }}
key: v3-dependencies-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json"}}

jobs:
checkout_code:
@@ -65,10 +65,15 @@ jobs:
# Restore node_modules from the last build
- restore_cache:
keys:
# Get latest cache for this package.json
- v2-dependencies-{{ checksum "package.json" }}
# Fallback to the last available cache
- v2-dependencies
# Get latest cache for this package.json and package-lock.json
- v3-dependencies-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "package-lock.json"}}
# Fallback to the current package.json
- v3-dependencies-{{ .Branch }}-{{ checksum "package.json" }}-
# Fallback to the last build for this branch
- v3-dependencies-{{ .Branch }}-
# Fallback to the last available master branch cache
- v3-dependencies-master-
# Don't go further down to prevent dependency issues from other branches
# Save project state for next steps
- persist_to_workspace:
root: /tmp
46 changes: 46 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
### Project specific config ###

language: go

matrix:
include:
- os: linux
go: "1.10"
env: ATOM_CHANNEL=stable

- os: linux
go: "1.10"
env: ATOM_CHANNEL=beta

install:
- go get -u github.com/pengwynn/flint

### 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

dist: trusty

addons:
apt:
packages:
- build-essential
- fakeroot
- git
- libsecret-1-dev
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

Lint projects using [`flint`][flint].

# Installation
## Installation

You need to have [`flint`][flint] installed on your system before using this
package. Once that is setup this package should work right away. If you are
@@ -13,6 +13,25 @@ As this package is just a wrapper around `flint`, you will need something to
actually run it. By default the [Linter][] package will be installed for you to
fill this need.

## Considerations

Since `flint` reports messages about the project as a whole there is no file to associate them to, so we mark them as coming from a "fake" `flint-messages` file. Unfortunately under the default settings for `linter-ui-default`, this means the messages from this provider will only ever show up in the status bar counts.

In order to show these messages you will need to change `linter-ui-default`'s Panel to represent the entire project in the settings.

The `status bar/panel` can be configured what `scope` of messages they are showing.

`linter-flint` actually runs when you open any file, but the messages it reports will be for a fake file that doesn't exist.

That means that they will never actually show in the project scoped panel by default, just in the status bar counts.

You would need to change their panel to `project scope`

```
Settings -> Packages -> linter-ui-default -> Panel Represents -> Entire Project
```

to see all messages for the project at once, `flint` messages will then show up.

[flint]: https://github.com/pengwynn/flint
[Linter]: https://atom.io/packages/linter
32 changes: 14 additions & 18 deletions lib/linter-flint.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
import { CompositeDisposable } from 'atom';
import { exec } from 'atom-linter';
import { dirname } from 'path';
import escapeHTML from 'escape-html';

// Internal vars
// Example: https://regex101.com/r/OfS9w0/2/
@@ -50,7 +49,7 @@ export default {
name: 'Flint',
grammarScopes: ['*'],
scope: 'project',
lintOnFly: false,
lintsOnChange: false,
lint: async (editor) => {
const filePath = editor.getPath();
let projectPath = atom.project.relativizePath(filePath)[0];
@@ -85,34 +84,31 @@ export default {

const output = await exec(this.executablePath, execArgs, execOpts);

const toReturn = [];
const messages = [];

let match = regex.exec(output);
while (match !== null) {
const [type, text, info, url] = match.slice(1);
const [type, excerpt, info, url] = match.slice(1);
if (type !== 'OK') {
const message = {
type: type === 'WARNING' ? 'Warning' : 'Error',
severity: type === 'WARNING' ? 'warning' : 'error',
text,
excerpt,
location: {
file: `${projectPath}/flint-messages`,
position: [[0, 0], [0, 0]],
},
};
if (url) {
message.url = url;
}
if (info) {
const trace = {
type: 'Trace',
severity: 'info',
};
if (url) {
trace.html = `${escapeHTML(info)} (<a href="${url}">link</a>)`;
} else {
trace.text = info;
}
message.trace = [trace];
message.description = info;
}
toReturn.push(message);
messages.push(message);
}
match = regex.exec(output);
}
return toReturn;
return messages;
},
};
},
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
"repository": "https://github.com/AtomLinter/linter-flint",
"license": "MIT",
"engines": {
"atom": ">=1.4.0 <2.0.0"
"atom": ">=1.9.0 <2.0.0"
},
"configSchema": {
"executablePath": {
@@ -42,14 +42,13 @@
"providedServices": {
"linter": {
"versions": {
"1.0.0": "provideLinter"
"2.0.0": "provideLinter"
}
}
},
"dependencies": {
"atom-linter": "10.0.0",
"atom-package-deps": "5.0.0",
"escape-html": "1.0.3"
"atom-package-deps": "5.0.0"
},
"devDependencies": {
"eslint": "5.14.1",
@@ -97,6 +96,6 @@
]
},
"package-deps": [
"linter"
"linter:2.0.0"
]
}
33 changes: 12 additions & 21 deletions spec/linter-flint-spec.js
Original file line number Diff line number Diff line change
@@ -31,31 +31,22 @@ describe('The Flint provider for Linter', () => {

it('checks a project with issues and reports the found issues', async () => {
atom.project.addPath(path.dirname(badPath));
const projectPath = atom.project.relativizePath(badPath)[0];
const editor = await atom.workspace.open(badPath);
const messages = await lint(editor);

expect(messages[0].type).toBe('Warning');
expect(messages[0].severity).toBe('warning');
expect(messages[0].html).not.toBeDefined();
expect(messages[0].text).toBe('Bootstrap script not found');
expect(messages[0].filePath).not.toBeDefined();
expect(messages[0].range).not.toBeDefined();
expect(messages[0].trace).toEqual([{
type: 'Trace',
severity: 'info',
html: 'A bootstrap script makes setup a snap. (<a href="http://bit.ly/JZjVL6">link</a>)',
}]);

expect(messages[1].type).toBe('Warning');
expect(messages[0].description).toBe('A bootstrap script makes setup a snap.');
expect(messages[0].url).toBe('http://bit.ly/JZjVL6');
expect(messages[0].excerpt).toBe('Bootstrap script not found');
expect(messages[0].location.file).toBe(`${projectPath}/flint-messages`);
expect(messages[0].location.position).toEqual([[0, 0], [0, 0]]);

expect(messages[1].severity).toBe('warning');
expect(messages[1].html).not.toBeDefined();
expect(messages[1].text).toBe('Test script not found');
expect(messages[1].filePath).not.toBeDefined();
expect(messages[1].range).not.toBeDefined();
expect(messages[1].trace).toEqual([{
type: 'Trace',
severity: 'info',
html: 'Make it easy to run the test suite regardless of project type. (<a href="http://bit.ly/JZjVL6">link</a>)',
}]);
expect(messages[1].description).toBe('Make it easy to run the test suite regardless of project type.');
expect(messages[1].url).toBe('http://bit.ly/JZjVL6');
expect(messages[1].excerpt).toBe('Test script not found');
expect(messages[1].location.file).toBe(`${projectPath}/flint-messages`);
expect(messages[1].location.position).toEqual([[0, 0], [0, 0]]);
});
});