shkola/eslint.config.js
2026-09-13 20:35:16 +00:00

54 lines
1.6 KiB
JavaScript

// ESLint flat config (ESLint 10.x) — dekart theme JS assets
// WordPress-контекст: скрипты темы — обычные <script>, не ES-модули.
// jQuery-обёртки, vendor-файлы и админ-скрипты обработаны отдельно.
'use strict';
const js = require('@eslint/js');
const globals = require('globals');
module.exports = [
// 1. Глобальный ignore — vendor, node_modules, сборки.
{
ignores: [
'node_modules/**',
'wp-content/themes/dekart/assets/js/owl.carousel.min.js',
'wp-content/themes/dekart/assets/vendor/**',
],
},
// 2. Базовые правила для всех JS.
js.configs.recommended,
// 3. Frontend-скрипты темы.
{
files: ['wp-content/themes/dekart/assets/js/**/*.js'],
languageOptions: {
ecmaVersion: 2020,
sourceType: 'script',
globals: {
...globals.browser,
...globals.jquery,
// Внешние скрипты: Яндекс.Карты, Метрика, Swiper.
ymaps: 'readonly',
yaCounter99835482: 'readonly',
Swiper: 'readonly',
},
},
rules: {
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'no-console': ['warn', { allow: ['warn', 'error'] }],
},
},
// 4. Админ-скрипты (admin-*.js) — отдельный контекст, без jQuery-глобалов.
{
files: ['wp-content/themes/dekart/assets/js/admin-*.js'],
languageOptions: {
ecmaVersion: 2020,
sourceType: 'script',
globals: {
...globals.browser,
},
},
},
];