Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of undefined (reading 'type') #3159

Open
lake2 opened this issue Feb 22, 2025 · 3 comments
Open

Cannot read properties of undefined (reading 'type') #3159

lake2 opened this issue Feb 22, 2025 · 3 comments

Comments

@lake2
Copy link

lake2 commented Feb 22, 2025

lint code as follow:

// https://prettier.io/docs/en/options.html

module.exports = {
    ...require('@xxxx/.prettierrc.js'),
};

crash:

Oops! Something went wrong! :(

ESLint: 9.18.0

TypeError: Cannot read properties of undefined (reading 'type')
@ljharb
Copy link
Member

ljharb commented Feb 22, 2025

Thanks - is there a stack trace? It would help to know which rule is crashing.

@lake2
Copy link
Author

lake2 commented Feb 22, 2025

Thanks - is there a stack trace? It would help to know which rule is crashing.

sorry, here is :

TypeError: Cannot read properties of undefined (reading 'type')
Occurred while linting D:\work\temp\pnpmfile\.prettierrc.js:3
Rule: "import/order"
    at AssignmentExpression (D:\work\temp\pnpmfile\node_modules\.pnpm\[email protected]_551368509ee4f17fa6c8c07c5f1396c1\node_modules\eslint-plugin-import\lib\rules\order.js:1058:50)
    at ruleErrorHandler (D:\work\temp\pnpmfile\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\linter\linter.js:1160:48)
    at D:\work\temp\pnpmfile\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (D:\work\temp\pnpmfile\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (D:\work\temp\pnpmfile\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\linter\node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (D:\work\temp\pnpmfile\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\linter\node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (D:\work\temp\pnpmfile\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\linter\node-event-generator.js:337:14)
    at runRules (D:\work\temp\pnpmfile\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\linter\linter.js:1204:40)
    at #flatVerifyWithoutProcessors (D:\work\temp\pnpmfile\node_modules\.pnpm\[email protected]\node_modules\eslint\lib\linter\linter.js:2001:31)
 ELIFECYCLE  Command failed with exit code 2.

@lake2
Copy link
Author

lake2 commented Feb 22, 2025

rules:

        {
            languageOptions: {
                parser,
                ecmaVersion: 'latest',
            },
            plugins: {
                import: importPlugin,
            },
            files: ['**/*.{js,jsx,ts,tsx,mjs,cjs}'],
            // ignores: ['*/node_modules/**/*'],
            rules: {
                'unicode-bom': ['error', 'never'],
                eqeqeq: ['warn', 'always'], // 
                'no-console': ['warn', { allow: ['warn', 'error'] }],
                'prefer-const': [
                    'error',
                    {
                        destructuring: 'any',
                        ignoreReadBeforeAssign: false,
                    },
                ],
                'no-useless-computed-key': 'error',
                'object-shorthand': 'error',
                'prefer-template': 'error',
                'import/newline-after-import': ['warn'], 
                'import/no-empty-named-blocks': ['warn'], 
                'import/no-duplicates': ['warn', { 'prefer-inline': true }], 
                'import/no-useless-path-segments': [
                    'error',
                    {
                        noUselessIndex: true,
                    },
                ],
                'import/order': [
                    // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md
                    'warn',
                    {
                        groups: ['builtin', 'external', 'internal', ['parent', 'index', 'sibling'], 'object'],
                        pathGroups: [
                            {
                                pattern: '@rife/**',
                                group: 'external',
                                position: 'after',
                            },
                            {
                                pattern: '@/**',
                                group: 'internal',
                                position: 'after',
                            },
                            {
                                pattern: 'src/**',
                                group: 'internal',
                                position: 'after',
                            },
                            // https://github.com/import-js/eslint-plugin-import/issues/1239#issuecomment-598064339
                            {
                                pattern: '**/*.+(css|sass|less|scss|pcss|styl)',
                                patternOptions: { dot: true, nocomment: true },
                                group: 'unknown',
                                position: 'after',
                            },
                            {
                                pattern: '{.,..}/**/*.+(css|sass|less|scss|pcss|styl)',
                                patternOptions: { dot: true, nocomment: true },
                                group: 'unknown',
                                position: 'after',
                            },
                            {
                                pattern: '**/*.+(svg|png|gif|jpg|jpeg|webp|bmp|ico)',
                                patternOptions: { dot: true, nocomment: true },
                                group: 'unknown',
                                position: 'after',
                            },
                            {
                                pattern: '{.,..}/**/*.+(svg|png|gif|jpg|jpeg|webp|bmp|ico)',
                                patternOptions: { dot: true, nocomment: true },
                                group: 'unknown',
                                position: 'after',
                            },
                        ],
                        pathGroupsExcludedImportTypes: [],
                        distinctGroup: false,
                        'newlines-between': 'always',
                        named: {
                            enabled: true,
                            types: 'types-first',
                        },
                        alphabetize: {
                            order: 'asc',
                        },
                    },
                ],
            },
        },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants