import js from '@eslint/js';
|
|
import prettierPlugin from 'eslint-plugin-prettier';
|
|
import prettierConfig from 'eslint-config-prettier';
|
|
|
|
export default [
|
|
js.configs.recommended,
|
|
{
|
|
files: ['**/*.js', '**/*.mjs'],
|
|
ignores: ['dist/**', 'node_modules/**', '*.min.js'],
|
|
plugins: {
|
|
prettier: prettierPlugin
|
|
},
|
|
languageOptions: {
|
|
ecmaVersion: 2022,
|
|
sourceType: 'module',
|
|
globals: {
|
|
// Browser globals
|
|
window: 'readonly',
|
|
document: 'readonly',
|
|
console: 'readonly',
|
|
localStorage: 'readonly',
|
|
sessionStorage: 'readonly',
|
|
navigator: 'readonly',
|
|
fetch: 'readonly',
|
|
URL: 'readonly',
|
|
URLSearchParams: 'readonly',
|
|
FormData: 'readonly',
|
|
FileReader: 'readonly',
|
|
Blob: 'readonly',
|
|
setTimeout: 'readonly',
|
|
setInterval: 'readonly',
|
|
clearTimeout: 'readonly',
|
|
clearInterval: 'readonly',
|
|
requestAnimationFrame: 'readonly',
|
|
cancelAnimationFrame: 'readonly',
|
|
alert: 'readonly',
|
|
confirm: 'readonly',
|
|
prompt: 'readonly',
|
|
location: 'readonly',
|
|
history: 'readonly',
|
|
CustomEvent: 'readonly',
|
|
Event: 'readonly',
|
|
EventTarget: 'readonly',
|
|
HTMLElement: 'readonly',
|
|
Element: 'readonly',
|
|
Node: 'readonly',
|
|
NodeList: 'readonly',
|
|
DOMParser: 'readonly',
|
|
XMLSerializer: 'readonly',
|
|
ResizeObserver: 'readonly',
|
|
MutationObserver: 'readonly',
|
|
IntersectionObserver: 'readonly',
|
|
|
|
// Node globals
|
|
process: 'readonly',
|
|
__dirname: 'readonly',
|
|
__filename: 'readonly',
|
|
Buffer: 'readonly',
|
|
global: 'readonly',
|
|
|
|
// Library globals
|
|
bootstrap: 'writable',
|
|
Chart: 'readonly',
|
|
moment: 'readonly',
|
|
Sortable: 'readonly',
|
|
TomSelect: 'readonly',
|
|
Quill: 'readonly',
|
|
DataTable: 'readonly',
|
|
FullCalendar: 'readonly'
|
|
}
|
|
},
|
|
rules: {
|
|
// Prettier integration
|
|
'prettier/prettier': 'error',
|
|
|
|
// Best Practices
|
|
'no-unused-vars': ['error', {
|
|
argsIgnorePattern: '^_',
|
|
varsIgnorePattern: '^_',
|
|
caughtErrorsIgnorePattern: '^_'
|
|
}],
|
|
'no-console': ['warn', { allow: ['warn', 'error', 'info'] }],
|
|
'no-debugger': 'error',
|
|
'no-alert': 'warn',
|
|
'no-var': 'error',
|
|
'prefer-const': 'error',
|
|
'prefer-arrow-callback': 'error',
|
|
'prefer-template': 'error',
|
|
'no-eval': 'error',
|
|
'no-implied-eval': 'error',
|
|
'no-new-func': 'error',
|
|
'no-script-url': 'error',
|
|
'no-with': 'error',
|
|
|
|
// Code Quality
|
|
'eqeqeq': ['error', 'always', { null: 'ignore' }],
|
|
'curly': ['error', 'all'],
|
|
'no-multi-spaces': 'error',
|
|
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }],
|
|
'no-trailing-spaces': 'error',
|
|
'semi': ['error', 'always'],
|
|
'quotes': ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
|
|
'comma-dangle': ['error', 'never'],
|
|
'comma-spacing': ['error', { before: false, after: true }],
|
|
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
|
|
'space-before-blocks': 'error',
|
|
'space-before-function-paren': ['error', {
|
|
anonymous: 'always',
|
|
named: 'never',
|
|
asyncArrow: 'always'
|
|
}],
|
|
'space-in-parens': ['error', 'never'],
|
|
'array-bracket-spacing': ['error', 'never'],
|
|
'object-curly-spacing': ['error', 'always'],
|
|
|
|
// ES6+ Features
|
|
'arrow-spacing': ['error', { before: true, after: true }],
|
|
'no-duplicate-imports': 'error',
|
|
'no-useless-constructor': 'error',
|
|
'no-useless-rename': 'error',
|
|
'object-shorthand': ['error', 'always', { avoidQuotes: true }],
|
|
'prefer-destructuring': ['error', {
|
|
array: false,
|
|
object: true
|
|
}, {
|
|
enforceForRenamedProperties: false
|
|
}],
|
|
|
|
// Async/Promise Rules
|
|
'no-async-promise-executor': 'error',
|
|
'no-await-in-loop': 'warn',
|
|
'no-promise-executor-return': 'error',
|
|
'prefer-promise-reject-errors': 'error'
|
|
}
|
|
},
|
|
prettierConfig
|
|
];
|