Closed as not planned
Closed as not planned
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
.
Repro Code
The code didn't matter, and it wouldn't work with anything.
ESLint Config
import nx from "@nx/eslint-plugin";
import eslintConfigPrettier from "eslint-config-prettier/flat";
import importPlugin from "eslint-plugin-import";
import jsdoc from "eslint-plugin-jsdoc";
import jsxA11y from "eslint-plugin-jsx-a11y";
import pluginLingui from "eslint-plugin-lingui";
import playwright from "eslint-plugin-playwright";
import react from "eslint-plugin-react";
import reactCompiler from "eslint-plugin-react-compiler";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import globals from "globals";
import tseslint from "typescript-eslint";
function createEsLintConfig(reactBase = false) {
return tseslint.config(
nx.configs["flat/base"],
nx.configs["flat/javascript"], // Already extends // js.configs.recommended,
nx.configs["flat/typescript"], // Almost same rules as ["flat/javascript"] but for ts files
jsdoc.configs["flat/recommended"],
tseslint.configs.strictTypeChecked,
tseslint.configs.stylisticTypeChecked,
// nx.configs["flat/react"],
reactBase && react.configs.flat.all,
reactBase && react.configs.flat["jsx-runtime"], // Add this if you are using React 17+
reactBase && reactHooks.configs["recommended-latest"],
reactBase && reactRefresh.configs.recommended,
reactBase && jsxA11y.flatConfigs.recommended,
reactBase && pluginLingui.configs["flat/recommended"],
reactBase && reactCompiler.configs.recommended,
// Todo: check if ignores is in the right place
{
ignores: [
"**/dist",
"**/vite.config.*.timestamp*",
"**/vitest.config.*.timestamp*",
],
},
// NX targeted config
{
files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
rules: {
"@nx/enforce-module-boundaries": [
"error",
{
allowCircularSelfDependency: true,
enforceBuildableLibDependency: true,
allow: [
"^.*/eslint(\\.base)?\\.config\\.[cm]?js$",
"^.*/vite(\\.base)?\\.config*",
],
depConstraints: [
{
sourceTag: "*",
onlyDependOnLibsWithTags: ["*"],
},
],
},
],
},
},
// Playwright
{
...playwright.configs["flat/recommended"],
files: ["tests/**"],
rules: {
...playwright.configs["flat/recommended"].rules,
// Customize Playwright rules
// ...
},
},
// Additional config
{
files: [
"**/*.ts",
"**/*.tsx",
"**/*.cts",
"**/*.mts",
"**/*.js",
"**/*.jsx",
"**/*.cjs",
"**/*.mjs",
],
// Override or add rules here
languageOptions: {
ecmaVersion: 2020,
globals: {
...globals.serviceworker,
...globals.browser,
},
parserOptions: {
ecmaVersion: "latest",
ecmaFeatures: { jsx: true },
sourceType: "module",
// Linting with Type Information: Start
projectService: {
parser: tseslint.parser,
allowDefaultProject: [
"eslint.base.config.mjs",
"eslint.config.mjs",
"prettier.config.mjs",
],
},
tsconfigRootDir: import.meta.dirname,
// Linting with Type Information: End
},
},
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
plugins: {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
...importPlugin.flatConfigs.recommended.plugins,
},
rules: (function () {
const baseRules = {
"@typescript-eslint/array-type": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/consistent-type-imports": [
"warn",
{
prefer: "type-imports",
fixStyle: "inline-type-imports",
},
],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ varsIgnorePattern: "^[A-Z_]" },
],
"no-redeclare": "off",
"@typescript-eslint/no-redeclare": "error",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-misused-promises": [
"error",
{
checksVoidReturn: {
attributes: false,
},
},
],
"jsdoc/require-jsdoc": "off",
"jsdoc/tag-lines": ["error", "any", { startLines: 1 }],
};
if (reactBase) {
const reactRules = {
// Safely merge React-specific rule configs
...Object.fromEntries(
nx.configs["flat/react"]
.map((config) => Object.entries(config.rules ?? {}))
.flat(),
),
...reactRefresh.configs.recommended.rules,
...reactCompiler.configs.recommended.rules,
...baseRules,
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"react/jsx-filename-extension": [1, { extensions: [".tsx"] }],
"react/jsx-no-bind": "off",
"react/jsx-max-depth": [2, { max: 4 }],
// TODO: check this and
"react/forbid-component-props": "off",
"react/jsx-no-literals": [
"warn",
{
noStrings: false,
ignoreProps: true,
allowedStrings: [],
noAttributeStrings: false,
elementOverrides: {
Trans: {
allowElement: true,
// applyToNestedElements: true
},
},
},
],
};
return reactRules;
}
return baseRules;
})(),
},
// Prettier must come last
eslintConfigPrettier,
);
}
export default createEsLintConfig(false);
tsconfig
Expected Result
It happened after upgrading, and I fixed it by downgrading to ^8.29.0
with the same config, and it worked.
Actual Result
- eslint.config.mjs: Config (unnamed): Unexpected non-object config at user-defined index 24.
Additional Info
No response