Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
lint api ok
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBitard committed Sep 12, 2024
1 parent ee2f311 commit da66d4d
Show file tree
Hide file tree
Showing 38 changed files with 146 additions and 172 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
],
"packages/ui/**/*.css": "prettier --write",
"packages/api/**/*.{js,ts}": [
"eslint --cache --fix --max-warnings=0",
"packages/api/node_modules/.bin/eslint --config packages/api/eslint.config.mjs --cache --fix --max-warnings=0",
"prettier --write"
],
"packages/api/**/*.{graphql,md}": "prettier --write",
Expand Down
9 changes: 0 additions & 9 deletions packages/api/.eslintignore

This file was deleted.

128 changes: 128 additions & 0 deletions packages/api/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin'
import sql from 'eslint-plugin-sql'
import globals from 'globals'
import tsParser from '@typescript-eslint/parser'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import js from '@eslint/js'
import { FlatCompat } from '@eslint/eslintrc'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
})

export default [
{
ignores: ['api-cache', 'backups', 'coverage', 'dist', 'docs', 'files', 'node_modules', 'sources', '**/*.queries.types.ts'],
},
...compat.extends('eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', 'standard', 'prettier'),
{
plugins: {
'@typescript-eslint': typescriptEslint,
sql,
},

languageOptions: {
globals: {
...globals.node,
GeoJSON: 'readonly',
},

parser: tsParser,
ecmaVersion: 5,
sourceType: 'commonjs',

parserOptions: {
project: true,
},
},

rules: {
camelcase: 0,

'sql/format': [
0,
{
ignoreExpressions: false,
ignoreInline: true,
ignoreTagless: true,
},
],

'sql/no-unsafe-query': [
2,
{
allowLiteral: false,
},
],

'newline-before-return': 1,
'no-use-before-define': 0,
'no-redeclare': 0,
'no-return-await': 'error',
'default-param-last': 0,
'no-unused-vars': 0,

'no-restricted-syntax': [
'error',
{
message: 'leftJoinRelation is deprecated. Use leftJoinRelated instead.',
selector: "Identifier[name='leftJoinRelation']",
},
{
message: 'sort is deprecated. Use toSorted instead.',
selector: "Identifier[name='sort']",
},
{
message: "no 'run' call from PgTyped allowed. Use dbQueryAndValidate.",
selector: "CallExpression[callee.property.name='run'][arguments.length=2]",
},
],

'no-console': [
'error',
{
allow: ['debug', 'info', 'warn', 'error', 'time', 'timeEnd'],
},
],

'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/explicit-module-boundary-types': 'warn',
'@typescript-eslint/no-empty-interface': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/ban-ts-comment': 0,

'@typescript-eslint/no-unused-vars': 0, // on utilise typescript noUnusedLocals et noUnusedParameters à la place

'@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/no-empty-object-type': 0,
},
},
{
files: ['src/database/models/*.ts'],

rules: {
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
},
},
{
files: ['src/**/*.ts'],
ignores: ['src/**/*.queries.ts'],

rules: {
'no-restricted-syntax': [
'error',
{
message: 'dbQueryAndValidate is to be used only in .queries.ts files',
selector: "CallExpression[callee.name='dbQueryAndValidate']",
},
],
},
},
]
117 changes: 0 additions & 117 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,122 +124,5 @@
"arrowParens": "avoid",
"trailingComma": "es5",
"printWidth": 200
},
"eslintConfig": {
"globals": {
"GeoJSON": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": true
},
"overrides": [
{
"files": [
"src/database/models/*.ts"
],
"rules": {
"@typescript-eslint/no-unsafe-declaration-merging": "off"
}
},
{
"files": [
"src/**/*.ts"
],
"excludedFiles": [
"src/**/*.queries.ts"
],
"rules": {
"no-restricted-syntax": [
"error",
{
"message": "dbQueryAndValidate is to be used only in .queries.ts files",
"selector": "CallExpression[callee.name='dbQueryAndValidate']"
}
]
}
}
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"standard",
"prettier"
],
"env": {
"node": true
},
"plugins": [
"@typescript-eslint",
"sql"
],
"rules": {
"camelcase": 0,
"sql/format": [
0,
{
"ignoreExpressions": false,
"ignoreInline": true,
"ignoreTagless": true
}
],
"sql/no-unsafe-query": [
2,
{
"allowLiteral": false
}
],
"newline-before-return": 1,
"no-use-before-define": 0,
"no-redeclare": 0,
"no-return-await": "error",
"default-param-last": 0,
"no-unused-vars": 0,
"no-restricted-syntax": [
"error",
{
"message": "leftJoinRelation is deprecated. Use leftJoinRelated instead.",
"selector": "Identifier[name='leftJoinRelation']"
},
{
"message": "sort is deprecated. Use toSorted instead.",
"selector": "Identifier[name='sort']"
},
{
"message": "no 'run' call from PgTyped allowed. Use dbQueryAndValidate.",
"selector": "CallExpression[callee.property.name='run'][arguments.length=2]"
}
],
"no-console": [
"error",
{
"allow": [
"debug",
"info",
"warn",
"error",
"time",
"timeEnd"
]
}
],
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/explicit-module-boundary-types": "warn",
"@typescript-eslint/no-empty-interface": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"@typescript-eslint/strict-boolean-expressions": "error",
"@typescript-eslint/no-empty-object-type": 0
}
}
}
1 change: 0 additions & 1 deletion packages/api/src/api/graphql/resolvers/_titre-activite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const productionCheck = (activiteTypeId: string, contenu: IContenu | null
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
return !!contenu?.renseignements?.orExtrait
} else if (activiteTypeId === 'wrp') {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const production = contenu?.renseignementsProduction

// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/api/rest/titre-demande.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const titreDemandeCreer: RestNewPostCall<'/rest/titres'> = (
pool: Pool,
user: DeepReadonly<UserNotNull>,
titreDemande: DeepReadonly<TitreDemande>,
// eslint-disable-next-line @typescript-eslint/ban-types
_params: {}
): Effect.Effect<TitreDemandeOutput, CaminoApiError<TitreDemandeCreerErrors>> => {
return Effect.Do.pipe(
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/business/matrices.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getRawLines, rawMatriceValidator } from './matrices'
import { describe, expect, test } from 'vitest'
import { BodyMatrice } from '../tools/matrices/tests-creation'
import { z } from 'zod'
const matricesProd = require('./matrices.cas.json')
const matricesProd = require('./matrices.cas.json') // eslint-disable-line

describe('matrices', () => {
const rawMatricesValidator = z.array(rawMatriceValidator)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable sql/no-unsafe-query */
import { titreEtapeUpdate } from '../../database/queries/titres-etapes'
import { titreEtapeHeritageContenuFind } from '../utils/titre-etape-heritage-contenu-find'
import { titreEtapesSortAscByOrdre, titreEtapesSortDescByOrdre } from '../utils/titre-etapes-sort'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { EtapeTypeEtapeStatutValidPair, EtapesTypesEtapesStatuts as ETES } from
import { Etape } from '../machine-common'
import { toCaminoDate } from 'camino-common/src/date'
import { describe, expect, test } from 'vitest'
const etapesProd = require('./2019-10-31-oct.cas.json')
const etapesProd = require('./2019-10-31-oct.cas.json') // eslint-disable-line

describe('vérifie l’arbre d’octroi d’ARM', () => {
const armOctMachine = new ArmOctMachine()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export class ArmOctMachine extends CaminoMachine<OctARMContext, XStateEvent> {
}
default:
// related to https://github.com/microsoft/TypeScript/issues/46497 https://github.com/microsoft/TypeScript/issues/40803 :(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

// @ts-ignore
return [{ type: event }]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ArmRenProMachine } from './ren-pro.machine'
import { interpretMachine, setDateAndOrderAndInterpretMachine } from '../machine-test-helper'
import { DemarchesStatutsIds } from 'camino-common/src/static/demarchesStatuts'
import { EtapesTypesEtapesStatuts as ETES } from 'camino-common/src/static/etapesTypesEtapesStatuts'
const etapesProd = require('./2019-10-31-ren-pro.cas.json')
const etapesProd = require('./2019-10-31-ren-pro.cas.json') // eslint-disable-line

describe('vérifie l’arbre de renonciation et de prolongation d’ARM', () => {
const armRenProMachine = new ArmRenProMachine()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { EtapesTypesEtapesStatuts as ETES } from 'camino-common/src/static/etape
import { ADMINISTRATION_IDS } from 'camino-common/src/static/administrations'
import { toCaminoDate } from 'camino-common/src/date'
import { describe, expect, test } from 'vitest'
const etapesProd = require('./2020-09-30-oct.cas.json')
const etapesProd = require('./2020-09-30-oct.cas.json') // eslint-disable-line

describe('vérifie l’arbre d’octroi d’AXM', () => {
const axmOctMachine = new AxmOctMachine()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class AxmOctMachine extends CaminoMachine<AxmContext, AXMOctXStateEvent>
return [{ type: event, date }]
default:
// related to https://github.com/microsoft/TypeScript/issues/46497 https://github.com/microsoft/TypeScript/issues/40803 :(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

// @ts-ignore
return [{ type: event }]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { describe, expect, test } from 'vitest'

import { EtapesTypesEtapesStatuts as ETES } from 'camino-common/src/static/etapesTypesEtapesStatuts'

const etapesProd = require('./2000-01-01-pro.cas.json')
const etapesProd = require('./2000-01-01-pro.cas.json') // eslint-disable-line

describe('vérifie l’arbre de prolongation d’AXM', () => {
const axmProMachine = new AxmProMachine()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class AxmProMachine extends CaminoMachine<AxmProContext, AXMProXStateEven
return [{ type: event, date }]
default:
// related to https://github.com/microsoft/TypeScript/issues/46497 https://github.com/microsoft/TypeScript/issues/40803 :(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

// @ts-ignore
return [{ type: event }]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PrmOctMachine } from './oct.machine'
import { EtapesTypesEtapesStatuts as ETES } from 'camino-common/src/static/etapesTypesEtapesStatuts'
import { describe, expect, test } from 'vitest'
import { PAYS_IDS } from 'camino-common/src/static/pays'
const etapesProd = require('./2019-10-31-oct.cas.json')
const etapesProd = require('./2019-10-31-oct.cas.json') // eslint-disable-line

describe('vérifie l’arbre d’octroi de PRM', () => {
const prmOctMachine = new PrmOctMachine()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class PrmOctMachine extends CaminoMachine<PrmOctContext, XStateEvent> {
]
default:
// related to https://github.com/microsoft/TypeScript/issues/46497 https://github.com/microsoft/TypeScript/issues/40803 :(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

// @ts-ignore
return [{ type: event }]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { describe, expect, test } from 'vitest'
import { DemarchesStatutsIds } from 'camino-common/src/static/demarchesStatuts'
import { ProcedureSimplifieeMachine } from './ps.machine'

const etapesProdProceduresHistoriques = require('../pxg-arg-cxr-inr-prr-pxr-cxf-prf-pxf/1717-01-09-amo-ces-con-dec-dep-exp-exs-fus-mut-oct-pr1-pr2-pre-pro-prr-ren-res-ret-vct-vut.cas.json')
const etapesProdProceduresHistoriques = require('../pxg-arg-cxr-inr-prr-pxr-cxf-prf-pxf/1717-01-09-amo-ces-con-dec-dep-exp-exs-fus-mut-oct-pr1-pr2-pre-pro-prr-ren-res-ret-vct-vut.cas.json') // eslint-disable-line
const psMachine = new ProcedureSimplifieeMachine()

describe('vérifie l’arbre des procédures historiques et simplifiées', () => {
Expand Down
Loading

0 comments on commit da66d4d

Please sign in to comment.