Git Product home page Git Product logo

18f-eslint-action's Introduction

18F eslint GitHub Action

A GitHub action for running the 18F configuration of ESLint on your project nice and easily. The simplest way to get this action installed into your repo is by using the action installer:

npx -p @18f/18f-eslint install-action

(NOTE the -p - this is required in order to run non-default commands.)

This command will begin at the root of your git repo, walk through your directory tree looking for package.json files, and add a step to lint the directories where each one is located. Once the basic action is installed, you can then go tweak the configuration.

The action configuration is in a yaml file to your project's .github/workflows/ directory with something like this in it:

name: lint action

on: [pull_request]

jobs:
  lint:
    name: 18F ESLint
    runs-on: ubuntu-latest
    container: node:14
    steps:
      - uses: actions/checkout@af513c7a
      - uses: 18f/[email protected]

In a super simple project, that might be all you need. From now on, all of your pull requests (and subsequent pushes to the same pull request) will have this action run on them. The action will fail if there are any lint errors.

Configuration

For somewhat more complicated projects (like, probably all of them), you can configure the action's working directory and the glob that it uses to find files for linting by setting its inputs. Inputs are set by adding them under a with property in the uses block for the action:

- uses: 18f/[email protected]
  with:
    lint-glob: **/*.js
    working-directory: src
variable default what it does
lint-glob . Indicates what files to run eslint on. This is any single glob that eslint supports.
only-changed false Indicates whether to only run eslint on changed files. Must be true to enable. This will override lint-glob.
working-directory . Indicates where to install @18f/18f-eslint. This must be the directory where your package.json is located.

The only-changed variable is useful for existing projects, so you can apply eslint only on files as you change them rather than having to update the whole project at once. Incremental linting!

Visit GitHub's documentation on workflow syntax for more information about configuring your workflow.

Notes about action refs

In the example yml above, the actions/github action is using a SHA ref rather than a version number. The reason is that it's very easy to change a commit's tag, but its SHA cannot be changed, so referring to a SHA is much safer.

For the 18f/18f-eslint-action action, it uses a tag rather than a SHA because 18F controls the repo and can make more guarantees about tags. It makes sense, therefore, to give our own repos more trust.

Public domain

This project is in the worldwide public domain. As stated in CONTRIBUTING:

This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.

All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.

18f-eslint-action's People

Contributors

mgwalker 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.