zbeekman / EditorConfig-Action

🔎A GitHub Action to check, enforce & fix EditorConfig style violations
https://github.com/marketplace/actions/editorconfig-action
MIT License
43 stars 15 forks source link
eclint editorconfig editorconfig-linter linter style stylelint
# EditorConfig-Action [![action on GH marketplace][marketplace badge]][marketplace]   [![gpg on keybase.io][keybase badge]][keybase]   [![GitHub release][release badge]][latest release]   [![package.json deps][npm dep badge]][eclint npm]   [![GitHub][LICENSE badge]][LICENSE]

:mag_right: A GitHub Action to check, enforce & fix EditorConfig style violations

[![blinking octocat][Blinky]][marketplace] ![squar-heart][sq heart] [![EditorConfig logo][EC logo]][EditorConfig]
Table of Contents

**Table of Contents** - [EditorConfig-Action](#editorconfig-action) - [What is EditorConfig?](#what-is-editorconfig) - [Using EditorConfig-Action with Your Project](#using-editorconfig-action-with-your-project) - [Example Workflows](#example-workflows) - [Check Conformance of Pushed Commits with `.editorconfig`](#check-conformance-of-pushed-commits-with-editorconfig) - [Features and Planed Features](#features-and-planed-features) - [EditorConfig Resources](#editorconfig-resources) - [Other GitHub Actions from @zbeekman](#other-github-actions-from-zbeekman)

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/EditorConfig-Action@v1.1.0"
  # 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/EditorConfig-Action@v1.1.0"
  # 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:

EditorConfig Resources

Other GitHub Actions from @zbeekman


[![star badge][star badge]][star]   [![zbeekman gh profile][gh follow]][gh profile]   [![zbeekman on twitter][twitter badge]][twitter]

[npm dep badge]: https://img.shields.io/github/package-json/dependency-version/zbeekman/EditorConfig-Action/eclint.svg