Code Monkey home page Code Monkey logo

editorconfig-action's Introduction

EditorConfig-Action

action on GH marketplace ย  gpg on keybase.io ย  GitHub release ย  package.json deps ย  GitHub

๐Ÿ”Ž A GitHub Action to check, enforce & fix EditorConfig style violations

blinking octocat squar-heart EditorConfig logo

Table of Contents

Table of Contents

What is EditorConfig?

From the EditorConfig website:

EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs. The EditorConfig project consists of a file format for defining coding styles and a collection of text editor plugins that enable editors to read the file format and adhere to defined styles. EditorConfig files are easily readable and they work nicely with version control systems.

Checkout this project's .editorconfig file here. However, to use this GitHub Action, your project should define your own .editorconfig.

This project uses eclint by Jed Mao (@jedmao) to lint your project. eclint is also released under an MIT license.

Using EditorConfig-Action with Your Project

Visit the EditorConfig-Action GitHub Marketplace page to get started. Use a tagged release or the master version of this GitHub action by creating your own .github/main.workflow file and adding a on = "push" and/or on = "pull_request" workflow that resolves an action uses = zbeekman/EditorConfig-Action[@ref]. Please see [the GitHub Actions documentation] for additional information.

Example Workflows

Check Conformance of Pushed Commits with .editorconfig

To ensure your repository does not violate your project's .editorconfig file, you may use the following workflow:

workflow "PR Audit" {
  on = "pull_request"
  resolves = ["EC Audit PR"]
}

action "EC Audit PR" {
  uses = "zbeekman/[email protected]"
  # secrets = ["GITHUB_TOKEN"] # Will be needed for fixing errors
  env = {
    ALWAYS_LINT_ALL_FILES = "false" # This is the default
  }
}

workflow "Push Audit" {
  on = "push"
  resolves = ["EC Audit Push"]
}

action "EC Audit Push" {
  uses = "zbeekman/[email protected]"
  # secrets = ["GITHUB_TOKEN"] # Will be needed for fixing errors
  env = {
    EC_FIX_ERROR = "false" # not yet implemented
    ALWAYS_LINT_ALL_FILES = "true" # Might be slow for large repos
  }
}

If you omit the ALWAYS_LINT_ALL_FILES variable or it is set to false then only files changed in the pushed commits will be linted. If you explicitly set this to true then every file in the repository will be checked. Depending on the size of the repository, this may be a bad idea.

For protected branches, it is best to set the required action to be the one created with the on = "pull_request", e.g., "EC Audit Push" above, since PRs from forks will not trigger a local push event.

Features and Planed Features

Features currently in development or being considered for addition include:

  • Check only files touched by commits included in the current push
  • Always check all files
  • Pull Request linting (lint all files in pull request) and provide PR status
  • Automatically apply fixes using eclint fix
  • Ability to pass search patterns to git ls-files for enumerating files to check
  • Ability to override project .editorconfig or use without an .editorconfig via eclint's property override flags
  • Pass patterns of files to ignore

EditorConfig Resources

Other GitHub Actions from @zbeekman


star badge ย  zbeekman gh profile ย  zbeekman on twitter

editorconfig-action's People

Contributors

dependabot-preview[bot] avatar zbeekman 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

Watchers

 avatar  avatar  avatar

editorconfig-action's Issues

Your .dependabot/config.yml contained invalid details

Dependabot encountered the following error when parsing your .dependabot/config.yml:

Automerging is not enabled for this account. You can enable it from the [account settings](https://app.dependabot.com/accounts/zbeekman/settings) screen in your Dependabot dashboard.
Automerging is not enabled for this account. You can enable it from the [account settings](https://app.dependabot.com/accounts/zbeekman/settings) screen in your Dependabot dashboard.

Please update the config file to conform with Dependabot's specification.

You can mention @dependabot in the comments below to contact the Dependabot team.

RFE: Ability to optionally pass flags directly to eclint

Describe the solution you'd like

eclint Accepts flags, mostly to override settings like indent_style, indent_size, etc. Add a mechanism to pass these directly. At the time of this writing eclint 2.8.1 supports the following flags:

Options:
  --help                          Show help                            [boolean]
  --version                       Show version number                  [boolean]
  --indent_style, -i              Indentation Style
                                            [choices: "tab", "space", undefined]
  --indent_size, -s               Indentation Size (in single-spaced characters)
                                                                        [number]
  --tab_width, -t                 Width of a single tabstop character   [number]
  --end_of_line, -e               Line ending file format (Unix, DOS, Mac)
                                        [choices: "lf", "crlf", "cr", undefined]
  --charset, -c                   File character encoding
    [choices: "latin1", "utf-8", "utf-8-bom", "utf-16le", "utf-16be", undefined]
  --trim_trailing_whitespace, -w  Denotes whether whitespace is allowed at the
                                  end of lines                         [boolean]
  --insert_final_newline, -n      Denotes whether file should end with a newline
                                                                       [boolean]
  --max_line_length, -m           Forces hard line wrapping after the amount of
                                  characters specified                  [number]
  --block_comment_start           Block comments start with             [string]
  --block_comment                 Lines in block comment start with     [string]
  --block_comment_end             Block comments end with               [string]

Describe alternatives you've considered

Doing nothing

DEFECT: npm audit failing in v1.1.1

npm audit is causing v1.1.1 to error. The solution is already committed to master, so it may be worth creating a new version for this fix.

RFE: Automatically apply fixes with `eclint`

Describe the solution you'd like

Use eclint fix to apply fixes when an option is set. A few considerations:

  • On protected branches, a pull request will need to be created. Something like <user/patch-n>.
  • On non-protected branches there should be an option to either push a new commit or create a new branch and open a PR.

Describe alternatives you've considered

Do nothing, keep current behavior

RFE: Lint pull request files

Is your feature request related to a problem? Please describe.

When not linting all files, EC lint failures in older commits will pass if the failing file is not touched in more recent commits. This is definitely not good for pull requests.

Describe the solution you'd like

When not linting all files, pull requests should trigger actions to lint all touched files in the pull request. This is probably a simple matter of adding an option for watching a pull-request event.

Describe alternatives you've considered

The only real alternative is to lint everything

DEFECT: Linting pushed commits passes when failing files are not touched in new commits

Describe the bug
Linting pushed commits pass when failing files are not fixed, but not touched

To Reproduce
Steps to reproduce the behavior:

  1. Push a commit with a file that fails
  2. Push another commit that changes a different file which conforms with .editorconfig

Expected behavior

Not sure... I think this makes sense, more or less, but, pull requests need to be handled in a smarter way.

Additional context

See also #8

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.