Skip to content

Commit 5b0befa

Browse files
committed
🚨 chore(api) fix audit logger linter config
1 parent 1deb8cd commit 5b0befa

File tree

5 files changed

+1399
-267
lines changed

5 files changed

+1399
-267
lines changed

audit-logger/.eslintignore

-133
This file was deleted.

audit-logger/eslint.config.cjs

-29
This file was deleted.

audit-logger/eslint.config.mjs

+181
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
import pixRecommendedConfig from '@1024pix/eslint-plugin/config';
2+
import babelParser from '@babel/eslint-parser';
3+
import { fixupPluginRules } from '@eslint/compat';
4+
import chai from 'eslint-plugin-chai-expect';
5+
import i18nJsonPlugin from 'eslint-plugin-i18n-json';
6+
import _import from 'eslint-plugin-import-x';
7+
import knex from 'eslint-plugin-knex';
8+
import mocha from 'eslint-plugin-mocha';
9+
import nRecommendedConfig from 'eslint-plugin-n';
10+
import prettierRecommendedConfig from 'eslint-plugin-prettier/recommended';
11+
import unicorn from 'eslint-plugin-unicorn';
12+
13+
const nonPhraseGeneratedFiles = ['translations/en.json', 'translations/fr.json'];
14+
15+
export default [
16+
...pixRecommendedConfig,
17+
prettierRecommendedConfig,
18+
nRecommendedConfig.configs['flat/recommended'],
19+
{ plugins: { 'chai-expect': fixupPluginRules(chai) } },
20+
{ plugins: { import: _import } },
21+
{ plugins: { knex: fixupPluginRules(knex) } },
22+
{ plugins: { unicorn } },
23+
{
24+
files: ['eslint.config.mjs'],
25+
rules: {
26+
'n/no-unpublished-import': 'off',
27+
'n/no-extraneous-import': 'off',
28+
},
29+
},
30+
{
31+
files: ['**/*.cjs'],
32+
languageOptions: {
33+
globals: { module: 'readonly', require: 'readonly' },
34+
},
35+
},
36+
{
37+
files: ['**/*.js'],
38+
languageOptions: {
39+
parser: babelParser,
40+
parserOptions: {
41+
ecmaVersion: 2020,
42+
sourceType: 'module',
43+
requireConfigFile: false,
44+
babelOptions: {
45+
configFile: false,
46+
babelrc: false,
47+
parserOpts: {
48+
plugins: ['importAttributes'],
49+
},
50+
},
51+
},
52+
},
53+
rules: {
54+
'no-console': 'error',
55+
'no-sync': 'error',
56+
'knex/avoid-injections': 'error',
57+
'no-empty-function': 'error',
58+
'n/no-process-exit': 'error',
59+
'unicorn/no-empty-file': 'error',
60+
'unicorn/prefer-node-protocol': 'error',
61+
'n/no-unpublished-import': 'off',
62+
'import/no-restricted-paths': [
63+
'error',
64+
{
65+
zones: [
66+
{
67+
target: ['api/lib/domain/usecases', 'lib/domain/usecases'],
68+
from: ['api/lib/infrastructure/repositories', 'lib/infrastructure/repositories'],
69+
except: [],
70+
message:
71+
"Repositories are automatically injected in use-case, you don't need to import them. Check for further details: https://github.com/1024pix/pix/blob/dev/docs/adr/0046-injecter-les-dependances-api.md",
72+
},
73+
{ target: 'tests/unit', from: 'db' },
74+
],
75+
},
76+
],
77+
},
78+
},
79+
{
80+
...mocha.configs.flat.recommended,
81+
files: ['tests/**/*.js'],
82+
rules: {
83+
...mocha.configs.flat.recommended.rules,
84+
'mocha/no-hooks-for-single-case': 'off',
85+
'mocha/no-exclusive-tests': 'error',
86+
'mocha/no-pending-tests': 'error',
87+
'mocha/no-skipped-tests': 'error',
88+
'mocha/no-top-level-hooks': 'error',
89+
'mocha/no-setup-in-describe': ['error'],
90+
},
91+
},
92+
{
93+
files: ['tests/integration/**/*.js'],
94+
rules: {
95+
'no-restricted-modules': [
96+
'error',
97+
{
98+
paths: ['@hapi/hapi'],
99+
},
100+
],
101+
},
102+
},
103+
{
104+
files: ['tests/integration/application/**/*.js'],
105+
rules: {
106+
'no-restricted-modules': [
107+
'error',
108+
{
109+
paths: [
110+
{
111+
name: '../../../server',
112+
message: 'Please use http-server-test instead.',
113+
},
114+
{
115+
name: '../../../../server',
116+
message: 'Please use http-server-test instead.',
117+
},
118+
],
119+
},
120+
],
121+
},
122+
},
123+
{
124+
files: ['tests/unit/**/*.js'],
125+
rules: {
126+
'no-restricted-imports': [
127+
'error',
128+
{
129+
paths: ['knex', 'pg'],
130+
},
131+
],
132+
},
133+
},
134+
{
135+
files: ['scripts/**/*.js'],
136+
rules: {
137+
'no-console': 'off',
138+
},
139+
},
140+
{
141+
files: ['lib/**/*.js'],
142+
rules: {
143+
'no-restricted-modules': [
144+
'error',
145+
{
146+
paths: [
147+
{
148+
name: 'axios',
149+
message: 'Please use http-agent instead (ADR 23)',
150+
},
151+
],
152+
},
153+
],
154+
'n/no-process-env': 'error',
155+
},
156+
},
157+
{
158+
files: ['lib/application/**/*.js'],
159+
rules: {
160+
'no-restricted-syntax': [
161+
'error',
162+
{
163+
selector: "CallExpression[callee.name='parseInt']",
164+
message:
165+
'parseInt is unnecessary here because Joi already casts string into number if the field is properly described (Joi.number())',
166+
},
167+
],
168+
},
169+
},
170+
{
171+
files: nonPhraseGeneratedFiles,
172+
plugins: { 'i18n-json': i18nJsonPlugin },
173+
processor: {
174+
meta: { name: '.json' },
175+
...i18nJsonPlugin.processors['.json'],
176+
},
177+
rules: {
178+
...i18nJsonPlugin.configs.recommended.rules,
179+
},
180+
},
181+
];

0 commit comments

Comments
 (0)