Skip to content

Commit

Permalink
Merge pull request #75 from TypedDevs/add-editor-config-lint
Browse files Browse the repository at this point in the history
Add editorconfig lint
  • Loading branch information
khru authored Sep 13, 2023
2 parents fc22919 + 19c5e6a commit 2550ee3
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 5 deletions.
11 changes: 9 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[**.sh]
indent_style = space
indent_size = 2
max_line_length = 120

[{Makefile,**.mk}]
indent_style = tab
max_line_length = off
12 changes: 12 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ make test/watch

## Coding Guidelines

### Shellcheck
To contribute to this repository you must have [shellcheck](https://github.com/koalaman/shellcheck) installed on your local machine or IDE, since it is the static code analyzer that is being used in continuous integration pipelines.

Installation: https://github.com/koalaman/shellcheck#installing
Expand All @@ -73,6 +74,17 @@ make lint
shellcheck ./**/**/*.sh -C
```

### Editorconfig checker
To contribute to this repository you must have installed [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) to check all the files of the project against the .editorconfig file of the project
to make sure that you fulfil the standard.

To run it use the following command:
```bash
ec -config .editorconfig
```

if you do not want to install this library on your local machine this command will be executed on the pipelines to ensure that the quality standards of the project

#### We recommend

To install the pre-commit of the project with the following command:
Expand Down
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
custom: ["https://chemaclass.com/sponsor"]
custom: ["https://chemaclass.com/sponsor"]
21 changes: 21 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
pull_request:
push:
branches:
- main

name: Editorconfig Linter

jobs:

tests:
name: "Run Lint on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ 'ubuntu-latest' ]
steps:
- uses: actions/checkout@v3
- uses: editorconfig-checker/action-editorconfig-checker@main
- run: editorconfig-checker

11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ SHELL=/bin/bash

-include .env

EDITOR_CONFIG_CHECKER := $(shell which ec 2> /dev/null)

OS:=
ifeq ($(OS),Windows_NT)
OS +=WIN32
Expand Down Expand Up @@ -71,11 +73,18 @@ pre_commit/install:
@echo "Installing pre-commit hooks"
cp $(PRE_COMMIT_SCRIPTS_FILE) ./.git/hooks/

pre_commit/run: test lint env/example
pre_commit/run: test lint editorconfig env/example

lint:
@shellcheck ./**/*.sh -C && printf "\e[1m\e[32m%s\e[0m\n" "Shellcheck: OK!"

editorconfig:
ifndef EDITOR_CONFIG_CHECKER
@printf "\e[1m\e[31m%s\e[0m\n" "Editorconfig check not installed checked not preformed"
else
@ec -config .editorconfig && printf "\e[1m\e[32m%s\e[0m\n" "Editorconfig check: OK!"
endif

test/example:
@./bashunit $(EXAMPLE_TEST_SCRIPTS)

Expand Down
6 changes: 5 additions & 1 deletion tests/unit/assert_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ function test_unsuccessful_assertArrayContains() {
local distros=(Ubuntu 1234 Linux\ Mint)

assertEquals\
"$(printFailedTest "Unsuccessful assertArrayContains" "Ubuntu 1234 Linux Mint" "to contain" "a_non_existing_element")"\
"$(printFailedTest\
"Unsuccessful assertArrayContains"\
"Ubuntu 1234 Linux Mint"\
"to contain"\
"a_non_existing_element")"\
"$(assertArrayContains "a_non_existing_element" "${distros[@]}")"
assertGeneralError "$(assertArrayContains "a_non_existing_element" "${distros[@]}")"
}
Expand Down

0 comments on commit 2550ee3

Please sign in to comment.