|
| 1 | +import js from "@eslint/js"; |
| 2 | +import eslintConfigPrettier from "eslint-config-prettier"; |
| 3 | +import headers from "eslint-plugin-headers"; |
| 4 | +import importX from "eslint-plugin-import-x"; |
| 5 | +import jest from "eslint-plugin-jest"; |
| 6 | +import markdownlint from "eslint-plugin-markdownlint"; |
| 7 | +import markdownlintParser from "eslint-plugin-markdownlint/parser.js"; |
| 8 | +import globals from "globals"; |
| 9 | +import tseslint from "typescript-eslint"; |
| 10 | + |
| 11 | +export default tseslint.config( |
| 12 | + // Global ignores (replaces .eslintignore) |
| 13 | + { |
| 14 | + ignores: [ |
| 15 | + "**/dist/", |
| 16 | + "**/build/", |
| 17 | + "**/cmake-build-*/", |
| 18 | + "**/coverage/", |
| 19 | + "**/node_modules/", |
| 20 | + "**/.idea/", |
| 21 | + ], |
| 22 | + }, |
| 23 | + |
| 24 | + // Base config for all JS/TS files |
| 25 | + js.configs.recommended, |
| 26 | + ...tseslint.configs.recommended, |
| 27 | + eslintConfigPrettier, |
| 28 | + importX.flatConfigs.recommended, |
| 29 | + importX.flatConfigs.typescript, |
| 30 | + |
| 31 | + // Global settings for JS/TS files |
| 32 | + { |
| 33 | + languageOptions: { |
| 34 | + globals: { |
| 35 | + ...globals.node, |
| 36 | + }, |
| 37 | + }, |
| 38 | + settings: { |
| 39 | + "import-x/resolver": { |
| 40 | + typescript: true, |
| 41 | + node: true, |
| 42 | + }, |
| 43 | + }, |
| 44 | + rules: { |
| 45 | + "import-x/no-named-as-default": "off", |
| 46 | + "import-x/no-named-as-default-member": "off", |
| 47 | + }, |
| 48 | + }, |
| 49 | + |
| 50 | + // JS/TS specific rules (replaces the *.js, *.ts override) |
| 51 | + { |
| 52 | + files: ["**/*.js", "**/*.ts"], |
| 53 | + plugins: { |
| 54 | + headers, |
| 55 | + }, |
| 56 | + rules: { |
| 57 | + "@typescript-eslint/ban-ts-comment": "off", |
| 58 | + "@typescript-eslint/no-require-imports": "off", |
| 59 | + "@typescript-eslint/no-unused-expressions": "off", |
| 60 | + "@typescript-eslint/no-unused-vars": "off", |
| 61 | + "headers/header-format": [ |
| 62 | + "error", |
| 63 | + { |
| 64 | + source: "string", |
| 65 | + blockPrefix: "\n", |
| 66 | + content: |
| 67 | + 'Copyright 2026 Code Intelligence GmbH\n\nLicensed under the Apache License, Version 2.0 (the "License");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.', |
| 68 | + }, |
| 69 | + ], |
| 70 | + "import-x/first": "error", |
| 71 | + "import-x/newline-after-import": "error", |
| 72 | + "import-x/no-unresolved": "warn", |
| 73 | + "import-x/order": [ |
| 74 | + "error", |
| 75 | + { |
| 76 | + alphabetize: { order: "asc", caseInsensitive: true }, |
| 77 | + "newlines-between": "always", |
| 78 | + distinctGroup: true, |
| 79 | + pathGroupsExcludedImportTypes: ["builtin"], |
| 80 | + pathGroups: [ |
| 81 | + { |
| 82 | + pattern: "@jazzer.js/**", |
| 83 | + group: "external", |
| 84 | + position: "after", |
| 85 | + }, |
| 86 | + ], |
| 87 | + }, |
| 88 | + ], |
| 89 | + "sort-imports": [ |
| 90 | + "error", |
| 91 | + { |
| 92 | + ignoreCase: true, |
| 93 | + ignoreDeclarationSort: true, |
| 94 | + }, |
| 95 | + ], |
| 96 | + }, |
| 97 | + }, |
| 98 | + |
| 99 | + // Exclude header check from the header template file itself |
| 100 | + { |
| 101 | + files: [".header.js"], |
| 102 | + rules: { |
| 103 | + "headers/header-format": "off", |
| 104 | + }, |
| 105 | + }, |
| 106 | + |
| 107 | + // Disable unresolved import warnings for examples/tests with their own deps |
| 108 | + { |
| 109 | + files: ["examples/**", "tests/**"], |
| 110 | + rules: { |
| 111 | + "import-x/no-unresolved": "off", |
| 112 | + }, |
| 113 | + }, |
| 114 | + |
| 115 | + // Jest globals for test and fuzz files |
| 116 | + { |
| 117 | + files: ["**/*.test.ts", "**/*.test.js", "**/*.fuzz.ts", "**/*.fuzz.js"], |
| 118 | + plugins: { |
| 119 | + jest, |
| 120 | + }, |
| 121 | + languageOptions: { |
| 122 | + globals: { |
| 123 | + ...globals.jest, |
| 124 | + }, |
| 125 | + }, |
| 126 | + }, |
| 127 | + |
| 128 | + // Markdown files |
| 129 | + { |
| 130 | + files: ["**/*.md"], |
| 131 | + plugins: { |
| 132 | + markdownlint, |
| 133 | + }, |
| 134 | + languageOptions: { |
| 135 | + parser: markdownlintParser, |
| 136 | + }, |
| 137 | + rules: { |
| 138 | + ...markdownlint.configs.recommended.rules, |
| 139 | + "markdownlint/md010": "off", |
| 140 | + "markdownlint/md013": "off", |
| 141 | + "markdownlint/md033": "off", |
| 142 | + "markdownlint/md041": "off", |
| 143 | + }, |
| 144 | + }, |
| 145 | +); |
0 commit comments