Files
twenty_crm/packages/twenty-server/.eslintrc.cjs
Paul Rastoin a8423e8503 [QRQC_2] No explicit any in twenty-server (#12068)
# Introduction

Added a no-explicit-any rule to the twenty-server, not applicable to
tests and integration tests folder

Related to https://github.com/twentyhq/core-team-issues/issues/975
Discussed with Charles

## In case of conflicts
Until this is approved I won't rebased and handle conflict, just need to
drop two latest commits and re run the scripts etc

## Legacy
We decided not to handle the existing lint error occurrences and
programmatically ignored them through a disable next line rule comment

## Open question
We might wanna activate the
[no-explicit-any](https://typescript-eslint.io/rules/no-explicit-any/)
`ignoreRestArgs` for our use case ?
```
    ignoreRestArgs?: boolean;
```

---------

Co-authored-by: etiennejouan <jouan.etienne@gmail.com>
2025-05-15 16:26:38 +02:00

122 lines
3.5 KiB
JavaScript

module.exports = {
plugins: ['@stylistic'],
extends: ['../../.eslintrc.global.cjs'],
ignorePatterns: [
'src/engine/workspace-manager/demo-objects-prefill-data/**',
'src/engine/seeder/data-seeds/**',
'src/engine/seeder/metadata-seeds/**',
'src/engine/core-modules/serverless/drivers/constants/base-typescript-project/src/index.ts',
],
overrides: [
{
files: ['**/*.ts'],
parserOptions: {
project: ['packages/twenty-server/tsconfig.json'],
},
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**../'],
message: 'Relative imports are not allowed.',
},
{
group: ['lodash'],
message:
"Please use the standalone lodash package (for instance: `import groupBy from 'lodash.groupby'` instead of `import { groupBy } from 'lodash'`)",
},
],
},
],
'@stylistic/linebreak-style': ['error', 'unix'],
'@stylistic/lines-between-class-members': [
'error',
{
enforce: [{ blankLine: 'always', prev: 'method', next: 'method' }],
},
],
'@stylistic/padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: 'return' },
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
{
blankLine: 'any',
prev: ['const', 'let', 'var'],
next: ['const', 'let', 'var'],
},
{ blankLine: 'always', prev: '*', next: ['interface', 'type'] },
],
'import/order': [
'error',
{
'newlines-between': 'always',
groups: [
'builtin',
'external',
'internal',
'type',
'parent',
'sibling',
'object',
'index',
],
pathGroups: [
{
pattern: '@nestjs/**',
group: 'builtin',
position: 'before',
},
{
pattern: '**/interfaces/**',
group: 'type',
position: 'before',
},
{
pattern: 'src/**',
group: 'parent',
position: 'before',
},
{
pattern: './*',
group: 'sibling',
position: 'before',
},
],
distinctGroup: true,
warnOnUnassignedImports: true,
pathGroupsExcludedImportTypes: ['@nestjs/**'],
},
],
'simple-import-sort/imports': 'off',
'unicorn/filename-case': 'off',
'prefer-arrow/prefer-arrow-functions': 'off',
'@nx/workspace-max-consts-per-file': 'off',
'@nx/workspace-inject-workspace-repository': 'warn',
},
},
{
files: [
'**/*.spec.ts',
'**/*.integration-spec.ts',
'**/__tests__/**',
'**/test/integration/**',
'**/test/utils/**',
],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
},
{
files: ['scripts/**/*.ts'],
parserOptions: {
project: ['packages/twenty-server/tsconfig.scripts.json'],
},
},
],
};