Giter VIP home page Giter VIP logo

lowercase-linter's Introduction

lowercase-linter

ci Maintainability Test Coverage

A GitHub Action to fail builds whos files have both upper and lower case mixed, i.e. camelCase to prevent filename conflicts and broken deployments.

Features

  • Suggests kebab-case fixes of problem filenames for quicker fixing
  • No dependencies* - to avoid supply chain security issues.
  • Ignores common mixed case files that usually won't "break" builds, e.g. CONTRIBUTING.md

*Note: GitHub Actions Toolkit is still required for JavaScript based actions.

Example Usage

steps:
  - name: Checkout
    uses: actions/checkout@v2

  - name: Lint Filenames
    uses: julie-ng/lowercase-linter@v1
    id: lint_filenames
    continue-on-error: true
    with:
      path: '.'
      pr-comment: true
      repo-token: ${{ secrets.GITHUB_TOKEN }}

Example Pull Request Comment

Use the pr-comment param to toggle whether you want suggested renames added to a pull request.

Example: Errors posted to Pull Request

Inputs

  • path (optional)

    Path to scan for mixed case filenames. Will search subfolders too.
    Default: .

  • pr-comment (optional)

    If file name errors are found, suggested fixes are posted to the Pull Request.
    Default: false

  • repo-token (optional)

    GitHub Action workflow token needed to add comments to pull requests.
    Default: ''

Outputs

  • errors

    Array - list of files with mixed case and suggested renames in JSON.

  • linted

    Array - list of all files that were checked for mixed case names.

  • comment-url

    String - URL of the comment posted to Pull Request (if errors were found).

Why is Case Sensitivity a Challenge?

If a system is case sensitive, then README.md and readme.md can co-exist.

If a system is not case sensitive, then Logo.png can be referenced both as its actual mixed case name and all lowercase logo.png. So if you have <img src="logo.png"> but your image is actually named Logo.png, it will work locally but users will see a broken image when deployed to a Linux based server.

System Case Sensistive
Windows false, but preserves case
Mac (HFS+) false, but preserves case
Git true
Linux true

Not deploying? Still a problem for colleagues. If you're collaborating and someone checks in a file with mixed case, it can be a nightmare to resolve because you have to do it in 2 places - OS and git. And if people don't keep their branches up to date, the mixed files come back like a recurring nightware ๐Ÿ˜ตโ€๐Ÿ’ซ

kebab-case suggestions

If you check the output, the action will also make suggestions using the kebab-case naming convention, for example:

Original name Suggested Name
Foo/Bar.md foo/bar.md
Foo/UppercaseExtension.MD foo/uppercase-extension.md
FooBar/cat.txt foobar/cat.txt
Foo foo

License

MIT

lowercase-linter's People

Contributors

julie-ng avatar

Watchers

 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.