mon-entreprise/.eslintrc.cjs

161 lines
4.2 KiB
JavaScript
Raw Normal View History

// eslint-disable-next-line no-undef
const tsconfigRootDir = __dirname
2021-12-07 12:46:03 +00:00
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
2021-12-07 12:46:03 +00:00
parserOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
ecmaFeatures: {
jsx: true,
},
},
env: {
browser: true,
commonjs: true,
es6: true,
},
globals: {
process: false,
},
extends: ['eslint:recommended', 'prettier'],
2021-12-07 12:46:03 +00:00
rules: {
'no-console': 'warn',
'no-restricted-globals': ['error', 'length'],
2021-12-07 12:46:03 +00:00
'no-restricted-syntax': [
'error',
{
message:
'Utilisez le composant <Emoji /> plutôt que la function emoji directement importée de react-easy-emoji',
selector: "CallExpression[callee.name='emoji']",
},
],
},
settings: {
react: {
version: 'detect',
},
},
overrides: [
{
files: ['**/*.{js,jsx}'],
env: { node: true },
},
2021-12-07 12:46:03 +00:00
{
files: ['**/*.{ts,tsx}'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: { jsx: true },
tsconfigRootDir,
project: ['*/tsconfig.json'],
2021-12-07 12:46:03 +00:00
},
extends: [
'eslint:recommended',
2022-04-04 13:47:07 +00:00
'standard',
2021-12-07 12:46:03 +00:00
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'prettier',
2021-12-07 12:46:03 +00:00
],
plugins: ['@typescript-eslint', 'react', 'react-hooks'],
rules: {
2022-04-04 15:06:21 +00:00
'no-void': 'off',
'ban-ts-comment': 'off',
2022-04-04 15:06:21 +00:00
'no-use-before-define': 'off',
'react/no-unescaped-entities': 'off',
'react/jsx-no-target-blank': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/member-delimiter-style': [
'error',
{ multiline: { delimiter: 'none' } },
],
2022-11-07 15:21:43 +00:00
'react/no-unknown-property': ['error', { ignore: ['css'] }],
2022-11-22 11:17:07 +00:00
/**
* Warning on props spreading cause typescript doesn't check type on it:
* https://github.com/microsoft/TypeScript/issues/18801#issuecomment-332610604
* Explicit spread is allow, example: <img {...{ prop1, prop2, prop3 }} />
*/
'react/jsx-props-no-spreading': ['warn', { explicitSpread: 'ignore' }],
2022-04-04 13:47:07 +00:00
// Auto fixable lint error
'prefer-const': 'error',
'padding-line-between-statements': [
'error',
// Require padding line before return statement
{ blankLine: 'always', prev: '*', next: 'return' },
//Require padding line after import
{ blankLine: 'always', prev: ['import', 'cjs-import'], next: '*' },
{
blankLine: 'any',
prev: ['import', 'cjs-import'],
next: ['import', 'cjs-import'],
},
//Require padding line before export
{ blankLine: 'always', prev: '*', next: ['export', 'cjs-export'] },
{
blankLine: 'any',
prev: ['export', 'cjs-export'],
next: ['export', 'cjs-export'],
},
],
},
2021-12-07 12:46:03 +00:00
},
// Cypress rules
2021-12-07 12:46:03 +00:00
{
files: ['site/cypress/**/*.ts'],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir,
project: ['site/cypress/tsconfig.json'],
2021-12-07 12:46:03 +00:00
},
extends: ['eslint:recommended', 'plugin:cypress/recommended', 'prettier'],
plugins: ['@typescript-eslint', 'cypress'],
rules: {},
},
{
files: ['site/cypress/**/*.js'],
extends: ['eslint:recommended', 'plugin:cypress/recommended', 'prettier'],
plugins: ['@typescript-eslint', 'cypress'],
rules: {},
},
// Jest rules (for Vitest)
{
files: ['site/test/**/*.{js,ts}'],
settings: { jest: { version: 28 } },
extends: ['eslint:recommended', 'plugin:jest/recommended', 'prettier'],
plugins: ['@typescript-eslint', 'jest'],
rules: {
'jest/valid-expect': 'off',
'jest/no-standalone-expect': [
'error',
{ additionalTestBlockFunctions: ['it', 'it.skip'] },
],
},
2021-12-07 12:46:03 +00:00
},
// Accessibility rules on /site
{
files: ['site/**/*.{jsx,js,tsx,ts}'],
plugins: ['jsx-a11y'],
extends: ['plugin:jsx-a11y/strict'],
rules: {
'jsx-a11y/no-autofocus': 'warn',
},
},
2021-12-07 12:46:03 +00:00
],
}