mirror of
https://github.com/directus/directus.git
synced 2026-01-09 18:48:02 -05:00
* Dangerously update API deps * Dangerously move app dependencies to pnpm-workspace * Move all dependencies to catalog * Sort catalog * Pnpm update * Use pnpm 10.14 * Update for zod breaking change * Fix unhead breaking change * Downgrade major api upgrades * Downgrade app major upgrades * Fix app tests * Downgrade isolated-vm * Add changeset * Fix template in head * Resolve unhead lang signature * Downgrade unhead * Downgrade keyv/redis It uses a different redis lib under the hood which is incompatible * Resolve import in test * Update and move workspace root dependencies * Update CSS for updated linter rules * Oops * Run formatter * Update rule name * Run prettier * Move utils peer to catalog * Add focus-trap dependency
140 lines
4.0 KiB
JavaScript
140 lines
4.0 KiB
JavaScript
// @ts-check
|
|
|
|
import eslintJs from '@eslint/js';
|
|
import eslintConfigPrettier from 'eslint-config-prettier';
|
|
import eslintPluginVue from 'eslint-plugin-vue';
|
|
import globals from 'globals';
|
|
import process from 'node:process';
|
|
import typescriptEslint from 'typescript-eslint';
|
|
|
|
export default typescriptEslint.config(
|
|
// Global config
|
|
{
|
|
languageOptions: {
|
|
ecmaVersion: 2023,
|
|
sourceType: 'module',
|
|
globals: {
|
|
...globals.browser,
|
|
...globals.node,
|
|
},
|
|
},
|
|
},
|
|
|
|
// Ignored files
|
|
{
|
|
ignores: ['**/dist/', 'packages/extensions-sdk/templates/', 'api/extensions/'],
|
|
},
|
|
|
|
// Enable recommended rules for JS files
|
|
eslintJs.configs.recommended,
|
|
|
|
// Custom basic rules
|
|
{
|
|
rules: {
|
|
// No console & debugger statements in production
|
|
'no-console': process.env.NODE_ENV !== 'development' ? 'error' : 'off',
|
|
'no-debugger': process.env.NODE_ENV !== 'development' ? 'error' : 'off',
|
|
// Require empty line between certain statements
|
|
'padding-line-between-statements': [
|
|
'error',
|
|
{
|
|
blankLine: 'always',
|
|
prev: [
|
|
'block',
|
|
'block-like',
|
|
'cjs-export',
|
|
'class',
|
|
'export',
|
|
'import',
|
|
'multiline-block-like',
|
|
'multiline-const',
|
|
'multiline-expression',
|
|
'multiline-let',
|
|
'multiline-var',
|
|
],
|
|
next: '*',
|
|
},
|
|
{
|
|
blankLine: 'always',
|
|
prev: ['const', 'let'],
|
|
next: ['block', 'block-like', 'cjs-export', 'class', 'export', 'import'],
|
|
},
|
|
{
|
|
blankLine: 'always',
|
|
prev: '*',
|
|
next: ['multiline-block-like', 'multiline-const', 'multiline-expression', 'multiline-let', 'multiline-var'],
|
|
},
|
|
{ blankLine: 'any', prev: ['export', 'import'], next: ['export', 'import'] },
|
|
],
|
|
// Require empty line between class members
|
|
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
|
|
// Disallow nested ternary expressions
|
|
'no-nested-ternary': 'error',
|
|
// Require brace style for multi-line control statements
|
|
curly: ['error', 'multi-line'],
|
|
// Disallow expressions where the operation doesn't affect the value
|
|
'no-constant-binary-expression': 'error',
|
|
},
|
|
},
|
|
|
|
// Enable TypeScript plugin and recommended rules for TypeScript files
|
|
...typescriptEslint.configs.recommended,
|
|
|
|
// Enable Vue plugin and recommended rules for Vue files
|
|
...eslintPluginVue.configs['flat/recommended'],
|
|
{
|
|
files: ['**/*.vue'],
|
|
languageOptions: { parserOptions: { parser: typescriptEslint.parser } },
|
|
// Apply recommended TypeScript rules to Vue files as well
|
|
// @ts-expect-error wrong type assertion
|
|
rules: typescriptEslint.configs.recommended.reduce((rules, config) => ({ ...rules, ...config.rules }), {}),
|
|
},
|
|
|
|
// Custom TypeScript rules
|
|
{
|
|
files: ['**/*.{ts,vue}'],
|
|
rules: {
|
|
// Allow unused arguments and variables when they begin with an underscore
|
|
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
|
// Allow ts-directive comments (used to suppress TypeScript compiler errors)
|
|
'@typescript-eslint/ban-ts-comment': 'off',
|
|
// Allow usage of the any type (consider enabling this rule later on)
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
},
|
|
},
|
|
|
|
// Custom Vue rules
|
|
{
|
|
files: ['**/*.vue'],
|
|
rules: {
|
|
// Same ordering of component tags everywhere
|
|
'vue/block-order': [
|
|
'error',
|
|
{
|
|
order: ['script', 'template', 'style'],
|
|
},
|
|
],
|
|
// Require empty line between component tags
|
|
'vue/padding-line-between-blocks': 'error',
|
|
// Allow single word component names ("Example" instead of "MyExample")
|
|
'vue/multi-word-component-names': 'off',
|
|
// Don't require default value for props that are not marked as required
|
|
'vue/require-default-prop': 'off',
|
|
// Require shorthand form attribute when v-bind value is true
|
|
'vue/prefer-true-attribute-shorthand': 'error',
|
|
// Allow unused variables when they begin with an underscore
|
|
'vue/no-unused-vars': ['error', { ignorePattern: '^_' }],
|
|
},
|
|
},
|
|
|
|
// Test files
|
|
{
|
|
files: ['**/*.test.ts'],
|
|
rules: {
|
|
'vue/one-component-per-file': 'off',
|
|
},
|
|
},
|
|
|
|
eslintConfigPrettier,
|
|
);
|