Skip to content

Commit

Permalink
Added linting and formatting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Johanna Ahlskog committed Sep 8, 2023
1 parent 5905b15 commit 8584370
Show file tree
Hide file tree
Showing 14 changed files with 1,263 additions and 6,799 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

32 changes: 32 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"ignorePatterns": ["node_modules", "test"],
"rules": {
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/typedef": [
"error",
{
"arrayDestructuring": true,
"arrowCallSignature": true,
"arrowParameter": true,
"callSignature": true,
"memberVariableDeclaration": true,
"parameter": true,
"propertyDeclaration": true,
"objectDestructuring": true,
"variableDeclaration": true,
"variableDeclarationIgnoreFunction": true
}
],
"@typescript-eslint/no-inferrable-types": 0,
"@typescript-eslint/naming-convention": ["error", { "selector": "variableLike", "format": ["camelCase"] }]
}
}

36 changes: 36 additions & 0 deletions .husky/husky.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env sh
if [ -z "$husky_skip_init" ]; then
debug () {
if [ "$HUSKY_DEBUG" = "1" ]; then
echo "husky (debug) - $1"
fi
}

readonly hook_name="$(basename -- "$0")"
debug "starting $hook_name..."

if [ "$HUSKY" = "0" ]; then
debug "HUSKY env variable is set to 0, skipping hook"
exit 0
fi

if [ -f ~/.huskyrc ]; then
debug "sourcing ~/.huskyrc"
. ~/.huskyrc
fi

readonly husky_skip_init=1
export husky_skip_init
sh -e "$0" "$@"
exitCode="$?"

if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
fi

if [ $exitCode = 127 ]; then
echo "husky - command not found in PATH=$PATH"
fi

exit $exitCode
fi
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist/
node_modules/
coverage/
coverage/
js_out/
README.md
2 changes: 0 additions & 2 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@
"arrowParens": "always",
"singleAttributePerLine": true
}


4 changes: 0 additions & 4 deletions CODEOWNERS

This file was deleted.

22 changes: 0 additions & 22 deletions LICENSE

This file was deleted.

26 changes: 26 additions & 0 deletions LinitingAndFormat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# How to install linting and format

1. Run the following commands (be in the root, if you don't have a package.json there, run npm init first to create one):

```yaml
npm install eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin husky prettier --save-dev
npm pkg set scripts.prepare="husky install"
npm run prepare
```

2. Copy files: .eslintrc.json, .prettierignore, .prettierrc and .husky/pre-commit

3. Add following to script section in package.json:

```json
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --fix --ext .ts",
"format:write": "npx prettier -w .",
"format:check": "npx prettier -c .",
```

4. Make a commit. You should see that your files are being checked for rule breaks. If it does not work and you are using a Mac, run following command and try a new commit:

```yaml
chmod ug+x .husky/*
```
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# CyDig Controls
# CyDig Azure Task

This repository contains workflows consisting of CyDig controls. There are 2 different approaches to scan your repositories. The first being on repository level, called *repository scan* (recommended) and the second being on a whole project, called *central scan*. The output of the scans are badges shown below:
This repository contains compliance tasks for Azure.

![numberOfReviewers](https://img.shields.io/badge/Number%20Of%20Reviewers-1-1eb03b)
![secureScore](https://img.shields.io/badge/Azure%20Security%20Score-100%25-1eb03b)
## Development instructions

*TODO*


By first running ```npm install``` in the root you get the linting and format rules downloaded. So, every time you make a commit, a pre-hook will run to validate the rules (Read more [here](https://github.com/Omegapoint/CydigAzureComplianceAction/blob/main/LinitingAndFormat.md). If there are any violation you will se an error or a warning in the terminal. To fix format warnings run the following command from the **root**:

```bash
npm run format:write
```

## Onboarding of CyDig in a GitHub project

TODO
*TODO*
39 changes: 0 additions & 39 deletions __tests__/index.test.ts

This file was deleted.

14 changes: 0 additions & 14 deletions action.yml

This file was deleted.

1 change: 0 additions & 1 deletion badges/coverage.svg

This file was deleted.

Loading

0 comments on commit 8584370

Please sign in to comment.