kbrgl / svelte-french-toast

šŸžšŸ„‚ Buttery smooth toast notifications for Svelte
https://svelte-french-toast.vercel.app/
MIT License
838 stars 30 forks source link

eslint import/order parse errors #17

Closed hmajid2301 closed 1 year ago

hmajid2301 commented 1 year ago

When I try to use this package with https://github.com/import-js/eslint-plugin-import I get the following error:

eslint . --fix

Checking formatting...
All matched files use Prettier code style!

Error while parsing /home/haseeb/projects/bookmarkey/gui/node_modules/svelte-french-toast/index.js
Line 2, column 9: Unexpected token
`parseForESLint` from parser `/home/haseeb/projects/bookmarkey/gui/node_modules/svelte-eslint-parser/lib/index.js` is invalid and will just be ignored

/home/haseeb/projects/bookmarkey/gui/src/routes/(unprotected)/(account)/login/+page.svelte
  3:20  error    Parse errors in imported module 'svelte-french-toast': parser.parse is not a function (undefined:undefined)  import/default
  3:20  warning  Parse errors in imported module 'svelte-french-toast': parser.parse is not a function (undefined:undefined)  import/no-named-as-default
  3:20  warning  Parse errors in imported module 'svelte-french-toast': parser.parse is not a function (undefined:undefined)  import/no-named-as-default-member

Where my eslint config file looks like:

module.exports = {
    root: true,
    parser: '@typescript-eslint/parser',
    parserOptions: {
        project: './tsconfig.json',
        extraFileExtensions: ['.svelte']
    },
    extends: [
        'eslint:recommended',
        'plugin:svelte/recommended',
        'plugin:@typescript-eslint/recommended',
        'prettier',
        'plugin:import/errors',
        'plugin:import/warnings',
        'plugin:import/typescript'
    ],
    plugins: ['@typescript-eslint'],
    ignorePatterns: ['*.cjs', 'svelte-french-toast'],
    overrides: [
        {
            files: ['*.svelte'],
            parser: 'svelte-eslint-parser',
            parserOptions: {
                parser: '@typescript-eslint/parser'
            }
        }
    ],
    settings: {
        // 'import/ignore': ['svelte-french-toast'],
        'svelte3/typescript': () => require('typescript')
    },
    parserOptions: {
        sourceType: 'module',
        ecmaVersion: 2020
    },
    env: {
        browser: true,
        es2017: true,
        node: true
    }
};

Adding this line 'import/ignore': ['svelte-french-toast'], in settings fixes this issue by ignoring it I believe, https://github.com/import-js/eslint-plugin-import#importignore. Any ideas what is actually is causing the issue ? It seems the parser cannot parse the index file in this library.

Thanks

kbrgl commented 1 year ago

Do you have a repo you could provide to reproduce the issue?

hmajid2301 commented 1 year ago

Here is the repo I have been using this library in https://gitlab.com/bookmarkey/gui

kbrgl commented 1 year ago

Closing since I don't think this is a Svelte French Toast issue. But Iā€™m pretty sure you should set up your ESLint to ignore anything under node_modules.