Coder Social home page Coder Social logo

linto's Introduction

linto ๐Ÿ’„

npm

A tool to test ESLint configurations against a set of GitHub repos.

Installation

yarn global add linto
# or if you have time to spare
npm install -g linto

Usage

linto run -c config.json

where config.json has the following structure:

{
  "repos": [{
    "owner": "buildo",
    "name": "linto"
  }],
  "eslintConfig": {
    "rules": {
      "semi": "error"
    }
  }
}

You can also write the config file in YAML format:

repos:
  - owner: buildo
    name: linto
eslintConfig:
  rules:
    semi: error

Target paths

By default, linto checks the src and the web/src directories of each repo. This default can be overridden on a repo base:

{
  "repos": [{
    "owner": "buildo",
    "name": "someMonoRepo",
    "paths": ["thefrontend/src"]
  }]
}

Plugin support

You can include any ESLint plugin in the config, as long as it's available on npm.

If, for example, you provide the following config

{
  "plugins": ["whatever"],
  "rules": {
    "whatever/rule": 2
  }
}

then linto will try to retrieve eslint-plugin-whatever from npm and make it available to ESLint.

Cleanup

linto creates temporary directories during its execution (to clone repos, install plugins, etc) and it cleans up after itself. However, in case linto is stopped during its execution, some of the directories it created may not be deleted. In order to remove all linto's temporary directories, you can run

linto clean

You can also perform a dry run, using -n or --dry-run:

linto clean -n # don't delete anything, just print what would be deleted

linto's People

Contributors

gabro avatar

Watchers

 avatar James Cloos avatar Giovanni Gonzaga avatar  avatar

linto's Issues

Hide npmi output completely

requirements

Despite the silent option npmi still outputs the dependency tree after installing the plugins. This

specs

This seems a recognized "misfeature" of npm: npm/npm#10732

The only option seems to be redirecting the stdout to dev null.

Run eslint --fix and automatically open pull requests

requirements

linto is great at finding whether a repo conforms to a new rule, but sometimes it could go a little further and actually fix the repo automatically (thanks to eslint --fix)
In those cases lint can open a PR for each offending repo and get most of the job done.

specs

Add a --fix mode to linto run that applies the automatic fixes and opens a PR for each repo that needs it.

Provide also a --dry-run flag to check the result before applying it.

Report unsupported node version

requirements

linto only supports node >= 6 and it fails miserably on previous versions of node with this error:

โฏ linto
/usr/local/lib/node_modules/linto/lib/index.js:8
const { CLIEngine } = require('eslint');
      ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:148:18)
    at node.js:405:3

We should handle this better.

specs

The engines options of package.json doesn't seem to do much, maybe a preinstall step?

Optionally allow extending the repo config

requirements

Some repos have a fairly custom ESLint config, like lexdoit.
On a repo-base (and possibly also globally) we should allow extending their configuration instead of starting from scratch.

This is potentially problematic when the config includes plugins and custom extends, but it should work fine if just install whatever it defines.

Filter report by a specific rule (or set of rules)

requirements

Apart from testing whole configurations, it may be useful to focus on a specific rule (or set of rules) in the report.

specs

Perform the linting as usual, but include only the selected rules in the report.

Support shareable configs

requirements

Add support for shareable configs.

Linto should be able to install shareable configs, as it does with plugins.

E.g. suppose you want to test a bunch of projects against the airbnb config.

specs

Same as plugins. Infer the npm package name and install.

Strip the temp folder path from error reporting

requirements

When printing the errors of each repo, you get something like

[buildo/hophop]
/private/var/folders/hf/c6z9xsp56lz679gcdn2d8t0h0000gn/T/tmp-50852g22NWNm651kp/src/toggl/index.js
  34:17  error  Strings must use singlequote  quotes

/private/var/folders/hf/c6z9xsp56lz679gcdn2d8t0h0000gn/T/tmp-50852g22NWNm651kp/src/utils/index.js
  93:17  error  Strings must use singlequote  quotes

โœ– 2 problems (2 errors, 0 warnings)

Ideally, this would be nicer

[buildo/hophop]
src/toggl/index.js
  34:17  error  Strings must use singlequote  quotes

src/utils/index.js
  93:17  error  Strings must use singlequote  quotes

โœ– 2 problems (2 errors, 0 warnings)

specs

Play with eslint formatters and potentially write a custom one.

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.