Code Monkey home page Code Monkey logo

vsource's Introduction

vsource

Add messages to a vfile bound to a plugin source.

npm status node Test JavaScript Style Guide

Usage

const vsource = require('vsource')
const vfile = require('vfile')

const file = vfile({ path: 'package.json' })
const s = vsource('my-lint-plugin', file)

// Add error message to file
s.fail('Name must be lowercase', pos, 'lowercase-name')

Which is just a convenient shortcut for:

file.fail('Name must be lowercase', pos, 'my-lint-plugin:lowercase-name')

In addition, fail() can be called multiple times to collect more than one error, unlike VFile#fail() which immediately terminates the process. I'm taking a slightly different approach to linting (than remark-lint et al): both error and warning messages are lint failures, but warnings can be ignored by the user. This behavior is closer to the standard linter. While remark-lint normally only produces warning messages, reserving error messages for unexpected exceptions.

API

s = vsource(source[, file])

If a file argument is provided, it does not have to be passed into the below methods.

message = s.fail([file, ]reason, position, ruleId)

Add error message to file, similar to VFile#fail(). Sets message.fatal to true.

message = s.warn([file, ]reason, position, ruleId)

Add warning message to file, same as VFile#message(). Sets message.fatal to false.

message = s.info([file, ]reason, position, ruleId)

Add info message to file, same as VFile#info(). Sets message.fatal to null.

Install

With npm do:

npm install vsource

License

MIT © Vincent Weevers

vsource's People

Contributors

dependabot[bot] avatar vweevers avatar

Watchers

 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.