Skip to content

Commit

Permalink
Merge pull request #44 from hasanheroglu/40-prettier-eslint-and-edito…
Browse files Browse the repository at this point in the history
…rconfig

40 prettier eslint and editorconfig
  • Loading branch information
egekorkan authored Oct 4, 2024
2 parents 66ee75b + 41ed9c8 commit a70e5b6
Show file tree
Hide file tree
Showing 101 changed files with 17,932 additions and 14,722 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[**.{ts,json,js}]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
94 changes: 94 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
module.exports = {
root: true,
extends: ["eslint:recommended", "standard", "prettier"],
plugins: ["unused-imports", "workspaces", "notice"],
env: {
es6: true,
node: true,
},
ignorePatterns: [".eslintrc.js", "dist", "node_modules"],
rules: {
"notice/notice": [
"error",
{
mustMatch:
"Copyright \\(c\\) [0-9]{0,4} Contributors to the Eclipse Foundation",
templateFile: __dirname + "/license.template.txt",
onNonMatchingHeader: "replace",
},
],
"no-use-before-define": "off",
"unused-imports/no-unused-imports": "error",
"guard-for-in": "error",
"unused-imports/no-unused-vars": [
"warn",
{
args: "none",
varsIgnorePattern: "Test", // Ignore test suites from unused-imports
},
],
},
overrides: [
{
files: ["**/*.ts", "**/*.tsx"],
parser: "@typescript-eslint/parser",
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.eslint.json"],
},
extends: [
"eslint:recommended",
"standard",
"prettier",
"plugin:@typescript-eslint/recommended",
"plugin:workspaces/recommended",
],
plugins: [
"@typescript-eslint",
"unused-imports",
"workspaces",
"notice",
],
env: {
es6: true,
node: true,
},
// ignorePatterns: [".eslintrc.js", "dist", "node_modules", "/examples", "bin", "*.js"],
rules: {
"notice/notice": [
"error",
{
mustMatch:
"Copyright \\(c\\) [0-9]{0,4} Contributors to the Eclipse Foundation",
templateFile: __dirname + "/license.template.txt",
onNonMatchingHeader: "replace",
},
],
"@typescript-eslint/no-unused-vars": "off", // or "@typescript-eslint/no-unused-vars": "off",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["error"],
"@typescript-eslint/prefer-nullish-coalescing": "error",
"unused-imports/no-unused-imports": "error",
"@typescript-eslint/strict-boolean-expressions": "error",
"guard-for-in": "error",
"unused-imports/no-unused-vars": [
"warn",
{
args: "none",
varsIgnorePattern: "Test", // Ignore test suites from unused-imports
},
],
},
},
{
files: ["**/*.test.js", "**/*.test.ts"],
env: {
mocha: true,
},
rules: {
"no-unused-expressions": "off",
"@typescript-eslint/no-unused-expressions": "off",
},
},
],
};
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CI Test Things

on:
push:
paths-ignore:
- "**.md"
- "**.png"
- "**.svg"
pull_request:
paths-ignore:
- "**.md"
- "**.png"
- "**.svg"

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- name: Checkout the branch
uses: actions/checkout@v3

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"

- name: Install dependencies
run: npm run setup

- name: Test Things
run: npm test

eslint:
name: eslint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Use Node.js 18
uses: actions/setup-node@v1
with:
node-version: 18

- name: Install
run: npm ci

- name: Lint
run: npm run lint

prettier:
name: Check coding style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actionsx/prettier@v2
with:
args: --check .
47 changes: 0 additions & 47 deletions .github/workflows/run-tests.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ __pycache__/

# TS files
dist/
.tsbuildinfo
*.tsbuildinfo
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package-lock.json
**/dist
coverage
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"printWidth": 120,
"singleQuote": false,
"tabWidth": 4,
"endOfLine": "lf"
}
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,29 +101,30 @@ See the mashup's [readme](./mashups/smart-home/README.md).
You can start the devices inside a container, for that running `docker-compose -f docker-compose-infra.yml -f docker-compose-things.yml up` at the root directory builds and runs the containers. For custom configuration, take a look at the `Dockerfile` of each device or [docker-compose-things.yml](./docker-compose-things.yml).

[docker-compose-things.yml](./docker-compose-things.yml) consists of the docker configuration of the things.
[docker-compose-infra.yml](./docker-compose-infra.yml) consists of the docker configuration of additional tools such as traefik, prometheus, grafana, cadvisor and portainer.
[docker-compose-infra.yml](./docker-compose-infra.yml) consists of the docker configuration of additional tools such as traefik, prometheus, grafana, cadvisor and portainer.

After the run, as default, the devices are accessible at:

| Thing Title | Access URL |
| ----------- | ---------- |
| http-advanced-coffee-machine | `http://localhost/http-advanced-coffee-machine` |
| coap-calculator-simple | `coap://localhost:5683/coap-calculator-simple` |
| coap-calculator-content-negotiation | `coap://localhost:5684/coap-calculator-content-negotiation` |
| http-express-calculator-simple | `http://localhost/http-express-calculator-simple` |
| Thing Title | Access URL |
| ------------------------------------------- | -------------------------------------------------------------- |
| http-advanced-coffee-machine | `http://localhost/http-advanced-coffee-machine` |
| coap-calculator-simple | `coap://localhost:5683/coap-calculator-simple` |
| coap-calculator-content-negotiation | `coap://localhost:5684/coap-calculator-content-negotiation` |
| http-express-calculator-simple | `http://localhost/http-express-calculator-simple` |
| http-express-calculator-content-negotiation | `http://localhost/http-express-calculator-content-negotiation` |
| http-flask-calculator | `http://localhost/http-flask-calculator` |
| mqtt-calculator | `mqtt://test.mosquitto.org:1883/mqtt-calculator` |
| modbus-elevator | `modbus+tcp://localhost:3179/1` |
| http-data-schema-thing | `http://localhost/http-data-schema-thing` |
| http-flask-calculator | `http://localhost/http-flask-calculator` |
| mqtt-calculator | `mqtt://test.mosquitto.org:1883/mqtt-calculator` |
| modbus-elevator | `modbus+tcp://localhost:3179/1` |
| http-data-schema-thing | `http://localhost/http-data-schema-thing` |

To be able to access additional tools, the user must login through GitHub. For GitHub authentication to work, environment variables `OAUTH_SECRET` and, `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` must be set with the configuration of GitHub OAuth application. Only whitelisted emails can access some of the services. Whitelisted emails can be set using the environment variable `WHITELISTED_EMAILS`. These services are accessible at:

- Traefik dashboard -> dashboard.localhost
- Traefik dashboard -> dashboard.localhost
- Prometheus -> prometheus.localhost
- cAdvisor -> cadvisor.localhost

Grafana and Portainer UIs are public access but they run their own authentication and authorization. These services are accessible at:

- Grafana -> grafana.localhost
- Portainer -> portainer.localhost

Expand All @@ -139,8 +140,9 @@ For Node.js-based devices, we use npm workspaces and running `npm install` at th

Grafana dashboard json files are stored in [./conf/grafana/dashboards](./conf/grafana/dashboards/).
To save your newly created dashboard locally and push it into the remote repository:
- Export the dashboard as JSON file using Share > Export.
- Save the exported JSON file to [./conf/grafana/dashboards](./conf/grafana/dashboards/).

- Export the dashboard as JSON file using Share > Export.
- Save the exported JSON file to [./conf/grafana/dashboards](./conf/grafana/dashboards/).

If your dashboard uses another datasource than our default `prometheus-datasource`, new datasource also must be provisioned in [./conf/grafana/datasources](./conf/grafana/provisioning/datasources/).
For more information check Grafana's provisioning [documentation](https://grafana.com/docs/grafana/latest/administration/provisioning/).
For more information check Grafana's provisioning [documentation](https://grafana.com/docs/grafana/latest/administration/provisioning/).
Loading

0 comments on commit a70e5b6

Please sign in to comment.