Giter Club home page Giter Club logo

atom-linter's Introduction

atom-linter

Greenkeeper badge

atom-linter is an npm helper module that you can import in your Linter Providers and make things easier for yourself.

API

For full documentation of exec and execNode API, please refer to sb-exec README

export const FindCache: Map
export function exec(command: String, args: Array<string> = [], options: Object): Promise
export function execNode(filePath: String, args: Array<string> = [], options: Object): Promise
export function parse(data: String, regex: String, options: Object = {flags: 'g'}): Array<Linter$Message>
export function generateRange(textEditor: TextEditor, lineNumber: Number = 0, colStart: Number = <firstTextColumn>): Array
export function find(directory: String, names: String | Array<string>): ?String
export function findCached(directory: String, names: String | Array<string>): ?String
export function findAsync(directory: String, names: String | Array<string>): Promise<?String>
export function findCachedAsync(directory: String, names: String | Array<string>): Promise<?String>
export function tempFile<T>(fileName: String, fileContents: String, callback: Function<T>): Promise<T>
export function tempFiles<T>(filesNames: Array<{ name: String, contents: String }>, callback: Function<T>): Promise<T>

Unique Spawning

To make sure that old processes spawned by your linter provider are terminated on a newer invocation, you can specify uniqueKey: "my-linter" in exec or execNode options. Please note that killed processes will return null as return value, so make sure to handle that.

Example:

import atomLinter from 'atom-linter'

const myLinterScope = 'file' // or "project"
const myLinter = {
  // ...
  scope: myLinterScope,
  async lint(textEditor) {
    const textEditorPath = textEditor.getPath()
    const output = atomLinter.exec('myprogram', ['parameter1', 'parameter2'], {
      uniqueKey: myLinterScope === 'file' ? `my-linter:${textEditorPath}` : 'my-linter'
    })
    // NOTE: Providers should also return null if they get null from exec
    // Returning null from provider will tell base linter to keep existing messages
    if (output === null) {
      return null
    }
    // ... parse output and return messages
    return []
  }
}

License

This project is licensed under the terms of MIT License, see the LICENSE file for more info

atom-linter's People

Contributors

steelbrain avatar arcanemagus avatar greenkeeper[bot] avatar greenkeeperio-bot avatar albertosantini avatar project0 avatar simon04 avatar benjaminromano avatar daw42 avatar hd-deman avatar keplersj avatar andystanton avatar

Watchers

James Cloos avatar Alexander Erhard avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.