Skip to content

Commit

Permalink
Merge pull request #32 from AplinkosMinisterija/prettier-lint-configs
Browse files Browse the repository at this point in the history
Prettier & eslint shared configs
  • Loading branch information
ambrazasp authored Nov 6, 2023
2 parents bfc0f14 + b46e067 commit 3e8eb07
Show file tree
Hide file tree
Showing 39 changed files with 599 additions and 2,008 deletions.
38 changes: 0 additions & 38 deletions .eslintrc.js

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Continuous integration

on:
push:
branches: [ main ]
branches: [main]
pull_request:

permissions: { }
permissions: {}

jobs:
build-test:
Expand All @@ -19,7 +19,7 @@ jobs:
postgres:
image: postgis/postgis:14-master
ports:
- "5331:5432"
- '5331:5432'
env:
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
Expand Down Expand Up @@ -66,4 +66,4 @@ jobs:
uses: AplinkosMinisterija/reusable-workflows/.github/actions/docker-build-tag-push@main
with:
environment: test
push: false
push: false
2 changes: 1 addition & 1 deletion .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy to Staging

on:
push:
branches: [ main ]
branches: [main]

jobs:
deploy-staging:
Expand Down
30 changes: 17 additions & 13 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: ESLint

on:
push:
branches: [ main ]
branches: [main]
pull_request:
schedule:
- cron: '39 5 * * 2'
Expand All @@ -11,28 +11,32 @@ jobs:
eslint:
name: Run eslint scanning
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
security-events: write
actions: read
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install ESLint
run: |
npm install eslint@8.10.0
npm install @microsoft/eslint-formatter-sarif@2.1.7
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version-file: package.json
cache: yarn

- name: Install dependencies
run: yarn install --immutable --immutable-cache --check-cache

- name: Run ESLint
run: npx eslint .
--config .eslintrc.js
--ext .js,.jsx,.ts,.tsx
--format @microsoft/eslint-formatter-sarif
--output-file eslint-results.sarif
run: yarn run lint:sarif
continue-on-error: true

- name: Upload analysis results to GitHub
- name: Upload ESLint analysis results to GitHub
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: eslint-results.sarif
wait-for-processing: true
wait-for-processing: true
category: ESLint
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,5 @@ dist

# IDE
.idea

eslint-results.sarif
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
7 changes: 0 additions & 7 deletions .prettierrc

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Ministerija.

- [About the Project](#about-the-project)
- [Getting Started](#getting-started)
- [Installation](#installation)
- [Usage](#usage)
- [Installation](#installation)
- [Usage](#usage)
- [Deployment](#deployment)
- [Contributing](#contributing)
- [License](#license)
Expand Down
4 changes: 3 additions & 1 deletion database/migrations/20230419183221_geometryFieldsFix.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ exports.up = function (knex) {
};

exports.down = function (knex) {
return knex.schema.raw(`ALTER TABLE fish_stockings ALTER COLUMN geom type geometry(geometry, 3346)`);
return knex.schema.raw(
`ALTER TABLE fish_stockings ALTER COLUMN geom type geometry(geometry, 3346)`,
);
};
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.5"
version: '3.5'

services:
postgres:
Expand Down Expand Up @@ -35,6 +35,5 @@ services:
networks:
internal:


volumes:
data:
2 changes: 1 addition & 1 deletion knexfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const config = {
tableName: 'migrations',
directory: './database/migrations',
},
pool: { min: 0, max: 10 },
pool: { min: 0, max: 7 },
...knexSnakeCaseMappers(),
};

Expand Down
10 changes: 2 additions & 8 deletions mixins/database.mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ export default function (opts: any = {}) {
},
};

opts = _.defaultsDeep(
opts,
{ adapter, createActions: { replace: false } },
{ cache: false },
);
opts = _.defaultsDeep(opts, { adapter, createActions: { replace: false } }, { cache: false });

const schema = {
mixins: [DbService(opts), filtersMixin()],
Expand All @@ -33,9 +29,7 @@ export default function (opts: any = {}) {
filterQueryIds(ids: Array<number>, queryIds?: any) {
if (!queryIds) return ids;

queryIds = (Array.isArray(queryIds) ? queryIds : [queryIds]).map(
(id: any) => parseInt(id),
);
queryIds = (Array.isArray(queryIds) ? queryIds : [queryIds]).map((id: any) => parseInt(id));

return ids.filter((id: number) => queryIds.indexOf(id) >= 0);
},
Expand Down
10 changes: 2 additions & 8 deletions modules/geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ export type CoordinatesPolygon = CoordinatesLine[];
export type CoordinatesMultiPolygon = CoordinatesPolygon[];
export type GeometryObject = {
type: string;
coordinates:
| CoordinatesPoint
| CoordinatesLine
| CoordinatesPolygon
| CoordinatesMultiPolygon;
coordinates: CoordinatesPoint | CoordinatesLine | CoordinatesPolygon | CoordinatesMultiPolygon;
};

export type GeomFeatureCollection = {
Expand Down Expand Up @@ -39,9 +35,7 @@ export function geometryToGeom(geometry: GeometryObject) {

export function geometriesToGeomCollection(geometries: GeometryObject[]) {
return `ST_AsText(ST_Collect(ARRAY(
SELECT ST_GeomFromGeoJSON(JSON_ARRAY_ELEMENTS('${JSON.stringify(
geometries,
)}'))
SELECT ST_GeomFromGeoJSON(JSON_ARRAY_ELEMENTS('${JSON.stringify(geometries)}'))
)))`;
}

Expand Down
7 changes: 1 addition & 6 deletions moleculer.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
'use strict';
import {
BrokerOptions,
Errors,
MetricRegistry,
ServiceBroker,
} from 'moleculer';
import { BrokerOptions, Errors, MetricRegistry, ServiceBroker } from 'moleculer';

require('@moleculer/lab');

Expand Down
48 changes: 21 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.8",
"description": "My Moleculer-based microservices project",
"private": true,
"prettier": "@aplinkosministerija/biip-prettier-config",
"scripts": {
"db:migrate": "knex migrate:latest",
"build": "tsc --build tsconfig.json",
Expand All @@ -13,92 +14,85 @@
"test:watch": "yarn run test --watch",
"test:coverage": "yarn run test --coverage",
"lint": "eslint --ext .js,.ts .",
"lint:sarif": "set SARIF_ESLINT_EMBED=true && yarn run lint --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif",
"dc:up": "docker compose -p zuvinimas-backend up --build -d",
"dc:down": "docker compose -p zuvinimas-backend down",
"dc:logs": "docker compose -p zuvinimas-backend logs -f"
"dc:logs": "docker compose -p zuvinimas-backend logs -f",
"prepare": "husky install"
},
"keywords": [
"microservices",
"moleculer"
],
"author": "",
"devDependencies": {
"@aplinkosministerija/biip-prettier-config": "^1.1.0",
"@aplinkosministerija/eslint-config-biip-api": "^1.0.0",
"@jest/globals": "^29.5.0",
"@types/bcrypt": "^5.0.0",
"@types/bcryptjs": "^2.4.2",
"@microsoft/eslint-formatter-sarif": "^3.0.0",
"@types/date-fns": "^2.6.0",
"@types/jest": "^29.5.0",
"@types/jsonwebtoken": "^9.0.1",
"@types/lodash": "^4.14.191",
"@types/mime-types": "^2.1.1",
"@types/minio": "^7.0.17",
"@types/node": "^18.15.3",
"@types/uuid": "^9.0.1",
"@types/qs": "^6.9.9",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3",
"jest": "^29.5.0",
"jest-cli": "^29.5.0",
"lint-staged": "14.0.1",
"mockdate": "^3.0.5",
"moleculer-repl": "^0.7.3",
"prettier": "2.8.4",
"prettier-plugin-organize-imports": "^3.2.2",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"typescript": "^5.0.2"
"typescript": "5.1.6"
},
"dependencies": {
"@faker-js/faker": "^7.6.0",
"@moleculer/database": "github:ambrazasp/moleculerjs-database",
"@moleculer/lab": "^0.6.4",
"@r2d2bzh/moleculer-cron": "^0.1.4",
"@stretchshop/moleculer-cron": "github:davidroman0O/moleculer-cron",
"@types/mkdirp": "^1.0.2",
"bcryptjs": "^2.4.3",
"biip-auth-nodejs": "github:dadpatch/biip-auth-nodejs",
"crypto": "^1.0.1",
"csv-parse": "^5.3.10",
"date-fns": "^2.29.3",
"dotenv": "^16.0.3",
"fast-json-patch": "^3.1.1",
"firebase-admin": "^11.5.0",
"hashids": "^2.2.11",
"ioredis": "^5.3.1",
"jaeger-client": "^3.19.0",
"jsonwebtoken": "^9.0.0",
"knex": "^2.4.2",
"lodash": "^4.17.21",
"mime-types": "^2.1.35",
"minio": "^7.0.33",
"mkdirp": "^2.1.5",
"moleculer": "^0.14.29",
"moleculer-auto-openapi": "^1.1.5",
"moleculer-db": "^0.8.23",
"moleculer-db-adapter-mongo": "^0.4.17",
"moleculer-decorators": "^1.3.0",
"moleculer-knex-filters": "github:DadPatch/moleculer-knex-filters",
"moleculer-minio": "github:zeckon/moleculer-minio",
"moleculer-plantuml": "github:dadpatch/moleculer-plantuml",
"moleculer-sentry": "^2.0.0",
"moleculer-web": "^0.10.5",
"mongodb": "^5.1.0",
"nats": "^2.13.1",
"objection": "^3.0.1",
"pg": "^8.10.0",
"pg-hstore": "^2.3.4",
"postmark": "^3.0.18",
"ramda-adjunct": "^3.4.0",
"sqlite3": "^5.1.6",
"stream-to-blob": "^2.0.1",
"transform-coordinates": "^1.0.0",
"uuid": "^9.0.0",
"xlsx": "^0.18.5"
},
"engines": {
"node": ">=18.0.0 <19.0.0"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"prettier --write",
"eslint"
],
"*.{md,html,css}": "prettier --write"
},
"eslintConfig": {
"extends": "@aplinkosministerija/eslint-config-biip-api"
}
}
Loading

0 comments on commit 3e8eb07

Please sign in to comment.