|
| 1 | +import js from '@eslint/js'; |
| 2 | +import globals from 'globals'; |
| 3 | +import json from '@eslint/json'; |
| 4 | +import markdown from '@eslint/markdown'; |
| 5 | +import { globalIgnores, defineConfig } from 'eslint/config'; |
| 6 | +import jest from 'eslint-plugin-jest'; |
| 7 | +import node from 'eslint-plugin-node'; |
| 8 | +import unicorn from 'eslint-plugin-unicorn'; |
| 9 | +import { fixupPluginRules } from '@eslint/compat'; |
| 10 | +import _import from 'eslint-plugin-import'; |
| 11 | + |
| 12 | +export default defineConfig([ |
| 13 | + // Non-required paths |
| 14 | + globalIgnores(['**/node_modules/', '.git/']), |
| 15 | + { |
| 16 | + files: ['**/*.{js,mjs,cjs}'], |
| 17 | + plugins: { |
| 18 | + js, |
| 19 | + node, |
| 20 | + unicorn, |
| 21 | + import: fixupPluginRules(_import), |
| 22 | + }, |
| 23 | + extends: ['js/recommended'], |
| 24 | + languageOptions: { |
| 25 | + ecmaVersion: 'latest', |
| 26 | + globals: { |
| 27 | + ...globals.node, |
| 28 | + ...globals.browser, |
| 29 | + }, |
| 30 | + }, |
| 31 | + rules: { |
| 32 | + 'semi': ['error', 'always'], |
| 33 | + 'prefer-const': 'error', |
| 34 | + 'no-unused-vars': 'error', |
| 35 | + 'max-len': ['error', { 'code': 120 }], |
| 36 | + // eslint-plugin-node |
| 37 | + 'node/no-missing-import': 'error', |
| 38 | + 'node/no-extraneous-import': 'error', |
| 39 | + 'node/file-extension-in-import': 'error', |
| 40 | + 'node/no-sync': 'off', |
| 41 | + // eslint-plugin-import |
| 42 | + 'import/no-unresolved': 'error', |
| 43 | + 'import/no-useless-path-segments': 'error', |
| 44 | + 'import/no-extraneous-dependencies': 'error', |
| 45 | + 'import/no-commonjs': 'error', |
| 46 | + // eslint-plugin-unicorn |
| 47 | + 'unicorn/prefer-module': 'error', |
| 48 | + 'unicorn/prefer-node-protocol': 'error', |
| 49 | + 'unicorn/prefer-top-level-await': 'error', |
| 50 | + }, |
| 51 | + }, |
| 52 | + { |
| 53 | + files: ['eslint.config.js'], |
| 54 | + rules: { |
| 55 | + // Disables the eslint/config not found message |
| 56 | + 'node/no-missing-import': 'off', |
| 57 | + 'import/no-unresolved': 'off', |
| 58 | + 'max-len': 'off', |
| 59 | + }, |
| 60 | + }, |
| 61 | + { |
| 62 | + files: ['**/*.json'], |
| 63 | + plugins: { json }, |
| 64 | + language: 'json/json', |
| 65 | + extends: ['json/recommended'] |
| 66 | + }, |
| 67 | + { |
| 68 | + files: ['package-lock.json'], |
| 69 | + rules: { |
| 70 | + 'json/no-empty-keys': 'off', |
| 71 | + }, |
| 72 | + }, |
| 73 | + { |
| 74 | + files: ['**/*.md'], |
| 75 | + plugins: { markdown }, |
| 76 | + language: 'markdown/gfm', |
| 77 | + extends: ['markdown/recommended'], |
| 78 | + // Allow special labels: alerts |
| 79 | + // https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts |
| 80 | + rules: { |
| 81 | + 'markdown/no-missing-label-refs': [ |
| 82 | + 'error', |
| 83 | + { |
| 84 | + allowLabels: [ |
| 85 | + '!NOTE', |
| 86 | + '!TIP', |
| 87 | + '!IMPORTANT', |
| 88 | + '!WARNING', |
| 89 | + '!CAUTION', |
| 90 | + ], |
| 91 | + }, |
| 92 | + ], |
| 93 | + }, |
| 94 | + }, |
| 95 | + { |
| 96 | + files: ['tests/*.js'], |
| 97 | + plugins: { |
| 98 | + js, |
| 99 | + jest |
| 100 | + }, |
| 101 | + extends: [ |
| 102 | + 'js/recommended', |
| 103 | + 'jest/recommended', |
| 104 | + ], |
| 105 | + rules: { |
| 106 | + 'max-len': 'off', |
| 107 | + }, |
| 108 | + }, |
| 109 | +]); |
0 commit comments