2024-07-04 14:25:35 +02:00
import js from '@eslint/js' ;
import globals from 'globals' ;
import importPlugin from 'eslint-plugin-import' ;
import localRules from 'eslint-plugin-local-rules' ;
import wcPlugin from 'eslint-plugin-wc' ;
import litPlugin from 'eslint-plugin-lit' ;
2024-07-02 11:37:25 +02:00
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended' ;
import tseslint from 'typescript-eslint' ;
2024-08-05 14:26:35 +02:00
import jsdoc from 'eslint-plugin-jsdoc' ;
2024-07-02 11:37:25 +02:00
export default [
// Recommended config applied to all files
js . configs . recommended ,
... tseslint . configs . recommended ,
2024-07-10 14:02:16 +02:00
wcPlugin . configs [ 'flat/recommended' ] ,
litPlugin . configs [ 'flat/recommended' ] ,
2024-08-06 13:24:55 +02:00
jsdoc . configs [ 'flat/recommended' ] , // We use the non typescript version to allow types to be defined in the jsdoc comments. This will allow js docs as an alternative to typescript types.
2024-07-10 14:02:16 +02:00
localRules . configs . all ,
2024-07-10 14:15:31 +02:00
eslintPluginPrettierRecommended ,
2024-07-02 11:37:25 +02:00
// Global ignores
{
2024-07-02 11:46:42 +02:00
ignores : [
2024-07-10 14:02:36 +02:00
'**/eslint.config.js' ,
2024-07-04 14:25:35 +02:00
'**/rollup.config.js' ,
'**/vite.config.ts' ,
'src/external' ,
'src/packages/core/icon-registry/icons' ,
'src/packages/core/icon-registry/icons.ts' ,
2024-07-10 14:02:36 +02:00
'src/**/*.test.ts' ,
2024-07-02 11:46:42 +02:00
] ,
2024-07-02 11:37:25 +02:00
} ,
// Global config
{
languageOptions : {
parserOptions : {
project : true ,
tsconfigRootDir : import . meta . dirname ,
} ,
globals : {
... globals . browser ,
2024-07-04 14:25:35 +02:00
} ,
2024-07-02 11:37:25 +02:00
} ,
plugins : {
import : importPlugin ,
2024-07-04 14:25:35 +02:00
'local-rules' : localRules ,
2024-07-02 11:37:25 +02:00
} ,
rules : {
2024-07-04 14:25:35 +02:00
semi : [ 'warn' , 'always' ] ,
2024-08-05 14:26:35 +02:00
'prettier/prettier' : [ 'warn' , { endOfLine : 'auto' } ] ,
2024-07-04 14:26:56 +02:00
'no-unused-vars' : 'off' , //Let '@typescript-eslint/no-unused-vars' catch the errors to allow unused function parameters (ex: in interfaces)
2024-07-04 14:25:35 +02:00
'no-var' : 'error' ,
2024-07-10 14:02:16 +02:00
... importPlugin . configs . recommended . rules ,
'import/namespace' : 'off' ,
2024-07-04 14:25:35 +02:00
'import/no-unresolved' : 'off' ,
'import/order' : [ 'warn' , { groups : [ 'builtin' , 'parent' , 'sibling' , 'index' , 'external' ] } ] ,
'import/no-self-import' : 'error' ,
'import/no-cycle' : [ 'error' , { maxDepth : 6 , allowUnsafeDynamicCyclicDependency : true } ] ,
2024-07-19 14:54:58 +02:00
'import/no-named-as-default' : 'off' , // Does not work with eslint 9
'import/no-named-as-default-member' : 'off' , // Does not work with eslint 9
2024-07-04 14:25:35 +02:00
'local-rules/prefer-static-styles-last' : 'warn' ,
'local-rules/enforce-umbraco-external-imports' : [
'error' ,
2024-07-02 11:37:25 +02:00
{
2024-07-04 14:25:35 +02:00
exceptions : [ '@umbraco-cms' , '@open-wc/testing' , '@storybook' , 'msw' , '.' , 'vite' ] ,
} ,
2024-07-02 11:37:25 +02:00
] ,
2024-07-04 14:25:35 +02:00
'local-rules/exported-string-constant-naming' : [
'error' ,
2024-07-02 11:37:25 +02:00
{
2024-07-04 14:25:35 +02:00
excludedFileNames : [ 'umbraco-package' , 'input-tiny-mce.defaults' ] , // TODO: what to do about the tiny mce defaults?
} ,
2024-07-02 11:37:25 +02:00
] ,
2024-07-04 14:25:35 +02:00
'@typescript-eslint/no-non-null-assertion' : 'off' ,
'@typescript-eslint/no-explicit-any' : 'warn' ,
2024-07-04 15:06:52 +02:00
'@typescript-eslint/no-unused-vars' : 'error' ,
2024-07-04 14:25:35 +02:00
'@typescript-eslint/consistent-type-exports' : 'error' ,
'@typescript-eslint/consistent-type-imports' : 'error' ,
'@typescript-eslint/no-import-type-side-effects' : 'warn' ,
} ,
2024-07-02 11:37:25 +02:00
} ,
// Pattern-specific overrides
{
files : [ '**/*.js' ] ,
... tseslint . configs . disableTypeChecked ,
languageOptions : {
globals : {
... globals . node ,
2024-07-04 14:25:35 +02:00
} ,
} ,
2024-07-02 11:37:25 +02:00
} ,
] ;