Skip to content

Commit

Permalink
Merge pull request #85 from Aiven-Open/add-linting-formatting-etc
Browse files Browse the repository at this point in the history
Add linting and formatting
  • Loading branch information
programmiri authored Sep 21, 2023
2 parents 00f9a4e + 3e2e8d2 commit 88f1315
Show file tree
Hide file tree
Showing 115 changed files with 5,257 additions and 2,460 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
37 changes: 37 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = {
root: true,
env: {
commonjs: true,
browser: true,
es2021: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:@docusaurus/recommended",
"plugin:json/recommended",
"plugin:react/recommended",
"prettier",
],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: "module",
},
plugins: ["json", "react"],
settings: {
react: {
version: "detect",
},
plugins: ["json", "react"],
settings: {
react: {
version: "detect",
},
},
rules: {},
ignorePatterns: ["build"],
},
};
13 changes: 13 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# Execute lint-staged jobs

echo "Pre=commit hook"
npm run lint-staged
if [ $? -ne 0 ]; then
echo -e '\n\n🙋 Check "lint-staged" in failed.'
echo -e ' Canceling the commit process.'
echo -e ' Please fix and try again!\n\n'
exit 1
fi

6 changes: 6 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default": true,
"MD013": false,
"MD030": false,
"MD046": false
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/hydrogen
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"trailingComma": "es5"
}
36 changes: 16 additions & 20 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand All @@ -60,7 +60,7 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[email protected].
`[email protected]`.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down Expand Up @@ -106,23 +106,19 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
This Code of Conduct is adapted from
the [Contributor Covenant](https://www.contributor-covenant.org), [version 2.0.](https://www.contributor-covenant.org/version/2/0/code_of_conduct),

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
For answers to common questions about this code of conduct, see the [FAQ](https://www.contributor-covenant.org/faq).
Contributor Covenant also offers [translations](https://www.contributor-covenant.org/translations).
77 changes: 76 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,78 @@
# Klaw documentation

Here is all the information you need to set up and work with this documentation repository.
- Please be aware of our [Code of Conduct](/CODE_OF_CONDUCT.md) ❤️

## About

This is the Klaw documentation repository. Welcome 👋 🎉
You can find source code and all content for our ([klaw-project.io](https://www.klaw-project.io/) site here.

## Installation and usage

### Requirements

- [node](https://nodejs.org/en/) needs to be installed.
-> please check [nvmrc](.nvmrc) or the `engines` definition in [package.json](package.json) for version.

This is the setup you every time. You can find the different ways how to run the local development process below.

### Local development

Install all needed dependencies and setup githooks:

```shell
npm install
```

To start local the local development server, run:

```shell
npm start
```

## Scripts used and what they execute

ℹ️ You can see all our scripts in the [`package.json`](package.json).
You can also run `npm run` in your console to get a list of all available scripts.

Here are the important ones you're likely to use:

- `npm start`: starts the app for development
- `npm run build`: will build the documentation site and generate all static files in "build". After `build` you can
run `npm run serve` to test your build locally
- `lint`: runs a format check and if no error is found, lints code and markdown files in the project.
- the linting script does not mutate your code. See [Linting and code formatting](#linting-and-code-formatting) for
more info.
- `reformat`: runs the code formatter (prettier) as well as the markdown linter in fix mode. This will mutate you code.

ℹ️ We are using a custom hook path for enabling pre-commit hooks. This path is set in the local git config when
running `npm install`.

## Linting and code formatting

How we keep our app's codebase looking consistent and nice 💅🏼

- [Prettier](https://prettier.io/) for code formatting
- [ESlint](https://eslint.org/) and various plugins for linting
- [markdownlint](https://github.com/DavidAnson/markdownlint) in combination
with [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli) to check and format markdown files
specially.

### Fine-grained scripts for linting and formatting

We provide `npm run lint` as well as `npm run reformat` to check or mutate your changes. We also offer more specific
scripts you can use:

Scripts with `lint` do not mutate your code in any way:

- `npm run lint:code` - runs a prettier and eslint check. This includes basic checks for markdown, but not
in depth.
- `npm run lint:markdown` - runs markdown-lint with more detailed check on markdown files.

To apply findings from `lint` and mutate your files:

- `npm run reformat:code` - runs prettier and eslint in fix mode.
- `npm run reformat:markdown` - runs markdownlint in fix mode.

ℹ️ It's convenient to let prettier and eslint auto-format your code "on save" by your IDE or editor. For markdownlint
you can find [plugins for some IDE/editors](https://github.com/DavidAnson/markdownlint#related), too.
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
presets: [require.resolve("@docusaurus/core/lib/babel/preset")],
};
Loading

0 comments on commit 88f1315

Please sign in to comment.