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 property 'filter' of undefined #9

Closed
RikuVan opened this issue Apr 27, 2019 · 10 comments
Closed

Cannot read property 'filter' of undefined #9

RikuVan opened this issue Apr 27, 2019 · 10 comments
Labels
invalid This doesn't seem right

Comments

@RikuVan
Copy link

RikuVan commented Apr 27, 2019

I am getting this error (trace below). I thought this was perhaps due to using the typescript parser but it seems to occur even if I remove the parser. Any suggestions would be much appreciated about how to proceed/ debug the issue.

eslintrc:

{
  "parser": "@typescript-eslint/parser",
  "plugins": ["svelte3", "@typescript-eslint"],
  "extends": "standard",
  "parserOptions": {
    "extraFileExtensions": [".svelte"]
  },
  "rules": {
    "semis": 0,
    "space-before-function-paren": 0,
    "no-console": "off"
  }
}
TypeError: Cannot read property 'filter' of undefined
    at preprocess (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint-plugin-svelte3/index.js:157:30)
    at Linter.verify (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint/lib/linter.js:954:13)
    at Linter.verify (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint-plugin-svelte3/index.js:303:17)
    at Linter.verifyAndFix (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint/lib/linter.js:1047:29)
    at processText (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint/lib/cli-engine.js:197:32)
    at processFile (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint/lib/cli-engine.js:241:12)
    at fileList.map.fileInfo (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint/lib/cli-engine.js:616:40)
    at Array.map (<anonymous>)
    at CLIEngine.executeOnFiles (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint/lib/cli-engine.js:588:34)
    at Object.execute (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint/lib/cli.js:205:111)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
➜  svelte-ts-starter git:(master) ✗ yarn run lint
yarn run v1.13.0
$ eslint src/**/*.ts src/**/*.svelte
<script>
  export let src =
    'https://images.pexels.com/photos/356378/pexels-photo-356378.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500'
  export let alt = 'white-dog'
</script>

<img
  src="https://images.pexels.com/photos/356378/pexels-photo-356378.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500"
  alt="hey"
/>

TypeError: Cannot read property 'filter' of undefined
    at preprocess (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint-plugin-svelte3/index.js:157:30)
    at Linter.verify (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint/lib/linter.js:954:13)
    at Linter.verify (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint-plugin-svelte3/index.js:303:17)
    at Linter.verifyAndFix (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint/lib/linter.js:1047:29)
    at processText (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint/lib/cli-engine.js:197:32)
    at processFile (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint/lib/cli-engine.js:241:12)
    at fileList.map.fileInfo (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint/lib/cli-engine.js:616:40)
    at Array.map (<anonymous>)
    at CLIEngine.executeOnFiles (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint/lib/cli-engine.js:588:34)
    at Object.execute (/Users/richard.vancamp/Code/Repos/svelte-ts-starter/node_modules/eslint/lib/cli.js:205:111)
@RikuVan
Copy link
Author

RikuVan commented Apr 27, 2019

By the way, it would be super helpful if you could provide an example of how the options, like ignoring styles, are actually used with the .eslintrc.

@Conduitry
Copy link
Member

I can't reproduce this. I have a package.json containing:

{
  "dependencies": {
    "@typescript-eslint/eslint-plugin": "^1.7.0",
    "@typescript-eslint/parser": "^1.7.0",
    "eslint": "^5.16.0",
    "eslint-config-standard": "^12.0.0",
    "eslint-plugin-import": "^2.17.2",
    "eslint-plugin-node": "^8.0.1",
    "eslint-plugin-promise": "^4.1.1",
    "eslint-plugin-standard": "^4.0.0",
    "eslint-plugin-svelte3": "^1.0.0",
    "svelte": "^3.1.0",
    "typescript": "^3.4.5"
  }
}

a .eslintrc containining:

{
  "root": true,
  "parser": "@typescript-eslint/parser",
  "plugins": ["svelte3", "@typescript-eslint"],
  "extends": "standard",
  "parserOptions": {
    "extraFileExtensions": [".svelte"]
  },
  "rules": {
    "semis": 0,
    "space-before-function-paren": 0,
    "no-console": "off"
  }
}

and a test.svelte containing:

<script>
  export let src =
    'https://images.pexels.com/photos/356378/pexels-photo-356378.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500'
  export let alt = 'white-dog'
</script>

<img
  src="https://images.pexels.com/photos/356378/pexels-photo-356378.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500"
  alt="hey"
/>

and when I run ./node_modules/.bin/eslint test.svelte I get no errors. If I edit the file to introduce a linting error (e.g., adding a semicolon), I do see that error.

Do you have a repo where I can reproduce this issue?

@RikuVan
Copy link
Author

RikuVan commented Apr 27, 2019

@RikuVan
Copy link
Author

RikuVan commented Apr 27, 2019

I can try later to put the code on online somewhere, e.g. codesandbox or glitch.

@Conduitry
Copy link
Member

When I clone that project, install dependencies, and run the lint script I get:

/.../svelte3-ts-starter/src/components/Image.svelte
  2:2  error  Parsing error: Expression expected

✖ 1 problem (1 error, 0 warnings)

@RikuVan
Copy link
Author

RikuVan commented Apr 27, 2019

sorry that was probably was slightly different than the version I had locally, which I now pushed--namely the linting was removed.

@RikuVan
Copy link
Author

RikuVan commented Apr 27, 2019

Anyways, if you don't get a similar issue, then I should do something in Glitch so we know it is not some other environment issue. node v11.10.0 by the way.

@Conduitry
Copy link
Member

Okay, thanks, yep I am seeing the same exception as you are now.

@Conduitry
Copy link
Member

https://github.com/RikuVan/svelte3-ts-starter/blob/master/yarn.lock#L2710 You're running Svelte 3 beta 3. Beta 4 introduced some changes to the output of the compiler that this plugin needs. You need to upgrade to a newer version, preferably one of the official non-beta releases from this past week.

@RikuVan
Copy link
Author

RikuVan commented Apr 27, 2019

oh no, sorry to trouble you with old version. Works now of course.

@Conduitry Conduitry added the invalid This doesn't seem right label Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants