Lost on parserPath or languageOptions.parser is required #119
Answered
by
nzakas
AdditionAddict
asked this question in
Q&A
-
I had /** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
env: {
browser: true,
commonjs: true,
es6: true,
},
ignorePatterns: ['!**/.server', '!**/.client'],
// Base config
extends: ['eslint:recommended'],
overrides: [
// React
{
files: ['**/*.{js,jsx,ts,tsx}'],
plugins: ['react', 'jsx-a11y'],
extends: [
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
],
settings: {
react: {
version: 'detect',
},
formComponents: ['Form'],
linkComponents: [
{ name: 'Link', linkAttribute: 'to' },
{ name: 'NavLink', linkAttribute: 'to' },
],
'import/resolver': {
typescript: {},
},
},
rules: {
// Disable specific React rules
'jsx-a11y/heading-has-content': 'warn',
'react/prop-types': 'warn',
'jsx-a11y/click-events-have-key-events': 'warn',
'jsx-a11y/no-noninteractive-element-interactions': 'warn',
'jsx-a11y/scope': 'warn',
},
},
// Typescript
{
files: ['**/*.{ts,tsx}'],
plugins: ['@typescript-eslint', 'import'],
parser: '@typescript-eslint/parser',
settings: {
'import/internal-regex': '^~/',
'import/resolver': {
node: {
extensions: ['.ts', '.tsx'],
},
typescript: {
alwaysTryTypes: true,
},
},
},
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
],
rules: {
// Disable specific TypeScript rules
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'import/no-unresolved': 'warn',
'react-hooks/exhaustive-deps': 'warn',
},
},
// Node
{
files: ['.eslintrc.cjs'],
env: {
node: true,
},
},
],
} This is basic remix example plus some ignores Running the migrate got me import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'
import { FlatCompat } from '@eslint/eslintrc'
import js from '@eslint/js'
import typescriptEslint from '@typescript-eslint/eslint-plugin'
import tsParser from '@typescript-eslint/parser'
import _import from 'eslint-plugin-import'
import jsxA11Y from 'eslint-plugin-jsx-a11y'
import react from 'eslint-plugin-react'
import globals from 'globals'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
})
export default [
{
ignores: [
'!**/.server',
'!**/.client',
'**/node_modules',
'.cache',
'build',
'**/.env',
'**/scripts',
],
},
...compat.extends('eslint:recommended'),
{
languageOptions: {
globals: {
...globals.browser,
...globals.commonjs,
},
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
},
...fixupConfigRules(
compat.extends(
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
),
).map((config) => ({
...config,
files: ['**/*.{js,jsx,ts,tsx}'],
})),
{
files: ['**/*.{js,jsx,ts,tsx}'],
plugins: {
react: fixupPluginRules(react),
'jsx-a11y': fixupPluginRules(jsxA11Y),
},
settings: {
react: {
version: 'detect',
},
formComponents: ['Form'],
linkComponents: [
{
name: 'Link',
linkAttribute: 'to',
},
{
name: 'NavLink',
linkAttribute: 'to',
},
],
'import/resolver': {
typescript: {},
},
},
rules: {
'jsx-a11y/heading-has-content': 'warn',
'react/prop-types': 'warn',
'jsx-a11y/click-events-have-key-events': 'warn',
'jsx-a11y/no-noninteractive-element-interactions': 'warn',
'jsx-a11y/scope': 'warn',
},
},
...fixupConfigRules(
compat.extends(
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
),
).map((config) => ({
...config,
files: ['**/*.{ts,tsx}'],
})),
{
files: ['**/*.{ts,tsx}'],
plugins: {
'@typescript-eslint': fixupPluginRules(typescriptEslint),
import: fixupPluginRules(_import),
},
languageOptions: {
parser: tsParser,
},
settings: {
'import/internal-regex': '^~/',
'import/resolver': {
node: {
extensions: ['.ts', '.tsx'],
},
typescript: {
alwaysTryTypes: true,
},
},
},
rules: {
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'import/no-unresolved': 'warn',
'react-hooks/exhaustive-deps': 'warn',
},
},
{
files: ['**/.eslintrc.cjs'],
languageOptions: {
globals: {
...globals.node,
},
},
},
] But I'm getting a bunch of /Users/andrew/extruda/extruda-supabase/apps/supervisor-app/app/site-instruction/$id.edit.tsx
9:23 error Parse errors in imported module 'tiny-invariant': parserPath or languageOptions.parser is required! (undefined:undefined) import/namespace
9:23 error Parse errors in imported module 'tiny-invariant': parserPath or languageOptions.parser is required! (undefined:undefined) import/default
/Users/andrew/extruda/extruda-supabase/apps/supervisor-app/app/site-instruction/$id.tsx
7:23 error Parse errors in imported module 'tiny-invariant': parserPath or languageOptions.parser is required! (undefined:undefined) import/namespace
7:23 error Parse errors in imported module 'tiny-invariant': parserPath or languageOptions.parser is required! (undefined:undefined) import/default
/Users/andrew/extruda/extruda-supabase/apps/supervisor-app/app/utils/auth.server.ts
2:30 error Parse errors in imported module 'remix-utils/safe-redirect': parserPath or languageOptions.parser is required! (undefined:undefined) import/namespace
/Users/andrew/extruda/extruda-supabase/apps/supervisor-app/vite.config.ts
3:27 error Parse errors in imported module 'vite-tsconfig-paths': parserPath or languageOptions.parser is required! (undefined:undefined) import/namespace
3:27 error Parse errors in imported module 'vite-tsconfig-paths': parserPath or languageOptions.parser is required! (undefined:undefined) import/default I can't find any result for parserPath or languageOptions.parser on the website so I'm a bit confused what's required here. |
Beta Was this translation helpful? Give feedback.
Answered by
nzakas
Sep 20, 2024
Replies: 1 comment 1 reply
-
These all come from |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
AdditionAddict
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These all come from
eslint-plugin-import
. You'll need to ask the maintainers of that plugin for help.