Code Monkey home page Code Monkey logo

eslint-action's Introduction

⚠️⚠️⚠️ You don't need this action ⚠️⚠️⚠️

Github Actions have everything that you need to run your eslint out of the box now, to do that simply use the run commands like so:

name: CI
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Install modules
      run: yarn
    - name: Run ESLint
      run: eslint . --ext .js,.jsx,.ts,.tsx

This action executes ESLint linter on specified javascript files without any previous action/build step or Docker required.

Prerequisites

ESLint

You must have the ESLint running locally for the action to execute. It will use the same rules as you do locally. More info on the ESLint getting started guide

Usage

main.yml

Add to your existing main.yml file or create a new file named .github/workflows/lint.yml and copy over one of the examples below to your new workflow file

This is the simplest example to get it running:

name: Lint

on: [push]

jobs:
  eslint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: stefanoeb/[email protected]

By default it will run ESLint through all the files in the project. But you can also specify a glob of files to lint using the with: argument on your YAML file. The example below shows ESLint running only on the files under the src/ folder:

name: Lint

on: [push]

jobs:
  eslint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: stefanoeb/[email protected]
        with:
          files: src/

If there is no previous step installing the necessary modules, this action will execute a yarn install or npm install automatically.

License

The Dockerfile and associated scripts and documentation in this project are released under the MIT License.

eslint-action's People

Contributors

bbosman avatar plata avatar raineorshine avatar rdil avatar stefanoeb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

eslint-action's Issues

Run only on changed files

Hello,

Is there any ways to run this actions only on changed files (not the entire repository files) ?

Unhelpful error when running action

Hi, I'm trying to use your linting action but even though i've followed your set up steps, and running eslint locally, I get the below message. Any ideas?

Screenshot 2020-03-11 at 16 16 44

Got an Error when I place package.json and source code in folder ./src

Run stefanoeb/[email protected]
/usr/bin/docker run --name d4dbb9d6b7741c98fcec8fea66e769b_88b5bd --label 442333 --workdir /github/workspace --rm -e working-directory -e INPUT_FILES -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/pivotal-webapp/pivotal-webapp":"/github/workspace" 442333:1d4dbb9d6b7741c98fcec8fea66e769b "src/"

Your environment is not ready yet. Installing modules...

Running ESLint

npm WARN saveError ENOENT: no such file or directory, open '/github/workspace/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/github/workspace/package.json'
npm WARN workspace No description
npm WARN workspace No repository field.
npm WARN workspace No README data
npm WARN workspace No license field.

up to date in 0.348s
found 0 vulnerabilities

sh: ./node_modules/.bin/eslint: not found

Using older versions of Node

Hi!
I'm supporting a project that still uses Node 8. We use Yarn with it. We plan to upgrade Node to version 12 but we haven't had time to do that yet.

Our CI setup uses your action like this:

  eslint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Use Node.js 8
        uses: actions/setup-node@v1
        with:
          node-version: '8.17.0'
      - name: Debug that we actually got node 8.17
        run: |
          echo $(node --version)
          echo $(npm --version)
      - uses: stefanoeb/[email protected]
        with:
          repo-token: ${{secrets.GITHUB_TOKEN}}

I confirmed that after using the actions/setup-node action, we're using node version 8.17.

Output of the stefanoeb/[email protected] step:

 /usr/bin/docker run --name c1aa2684b8e729a49fcba82cbc58a27ebb6_ab7d7f --label 430c1a --workdir /github/workspace --rm -e INPUT_REPO-TOKEN -e INPUT_FILES -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/appname/appname":"/github/workspace" 430c1a:a2684b8e729a49fcba82cbc58a27ebb6  "."
## Your environment is not ready yet. Installing modules...
## Running ESLint
error [email protected]: The engine "node" is incompatible with this module. Expected version "8.17.0". Got "10.14.1"
error [email protected]: The engine "yarn" is incompatible with this module. Expected version ">=1.17.3". Got "1.12.3"
error Found incompatible module

It seems that because your Dockerfile is based off of Node 10, there's a version mismatch when trying to run eslint on our repo.
https://github.com/stefanoeb/eslint-action/blob/master/Dockerfile#L1

Is there a way to get around this? Or is it required that we run the same version of Node as the image used in the Dockerfile?

Thanks!

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.