SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: meenedit on October 14, 2021, 05:10:45 pm

Title: Error Parsing for ESLint
Post by: meenedit on October 14, 2021, 05:10:45 pm
Hi all

I try to run ESlint for Typescript files in TypeScript mode. However, I get no result, and I can't find the reason (SlickEdit Pro 2021, v26.0.0.6, Project Type: Other, Language: .tsx TypeScript).

Live Error Profile configuration (Document > TypeScript Options > Live Error Profiles).

Code: [Select]
Program: /usr/local/bin/eslint
Command line: -f compact "%f"
Run from dir: %rw

I developed a custom regular expression for error parsing to ensure the error messages are understandable for SlickEdit:

Code: [Select]

The error messages looking like this:

Code: [Select]
/Users/theUser/Projects/node/src/server/components/HTML.tsx: line 8, col 1, Error - Delete `··` (prettier/prettier)
/Users/theUser/Projects/node/src/server/components/HTML.tsx: line 11, col 14, Warning - Missing return type on function. (@typescript-eslint/explicit-module-boundary-types)
/Users/theUser/Projects/node/src/server/components/HTML.tsx: line 11, col 16, Error - Replace `⏎····children,⏎····css·=·[],⏎····scripts·=·[],⏎····state·=·'{}',⏎····helmetContext:·{·helmet·},⏎` with `·children,·css·=·[],·scripts·=·[],·state·=·'{}',·helmetContext:·{·helmet·}·` (prettier/prettier)
/Users/theUser/Projects/node/src/server/components/HTML.tsx: line 18, col 1, Error - Replace `····` with `··` (prettier/prettier)

I tested my custom regular expression in SlickEdit's "Regex Evaluator," and it looks good. Next, I added the Regex to Build > Configure Error Parsing in the section "User" and ran the validation. With the error messages above, I got four validated results:

Code: [Select]
Matched expression on line #1
Filename: /Users/theUser/Projects/node/src/server/components/HTML.tsx
Line #: 8
Column: 1
Message: Error - Delete `··` (prettier/prettier)

Finally, I disabled all expressions except the "User" category and restarted SlickEdit.

However, SlickEdit won't show me any message for my *.tsx-files. The Message List pane is always empty – but I see ESLint-errors when I run ESLint in the terminal. What did I do wrong?

Thank you very much for some helpful hints.
Title: Re: Error Parsing for ESLint
Post by: patrick on October 14, 2021, 06:29:25 pm
If you open up a tsx file in SlickEdit,  there should be a file created in your configuration directory called rte/rteout.    (Look in the help -> about dialog for the location of your configuration directory if you're not sure where it is).  Does that file have the error messages for the file you opened, in the correct format?

Also, on the Live Errors configuration page, make sure enabled is clicked (I've left that off several times myself), and make sure the Default Profile combo box has your eslint profile selected, so we know Auto Detect hasn't picked the built in tsc profile instead.

If it's not any of those, can you post the part of your eslintrc that sets that format up? I can use that to try to reproduce the problem here.

Title: Re: Error Parsing for ESLint
Post by: meenedit on October 14, 2021, 09:10:49 pm
Hi patrick

Thank you very much for your fast reply. Your instructions helped me to fix my problem. It was across multiple layers.

1.) env: node: No such file or directory

Code: [Select]
$ cat ~/Library/Application\ Support/SlickEdit/26.0.0/rte/rteout
env: node: No such file or directory

To fix this, I had to expand the path variable in my "Life Error Profile" (because my "node" is in /usr/local/bin/node

Code: [Select]
   Program: /usr/local/bin/eslint
   Command line: -f compact "%f"
   Run from dir: %rw
+ Environment vars to set:
+     PATH=/usr/local/bin:/usr/local/sbin:$PATH

2.) Updated regular expression

After fixing the Path variable for the "Live Error Profile" I noticed, SlickEdit  does not use the original file route in `rteout`:

Code: [Select]
/Users/theUser/Library/Application Support/SlickEdit/26.0.0/rte/index.tsx: line 1, col 24, Error - Replace `'react'` with `"react"` (prettier/prettier)

Validating this output failed with my existing regular expression. I had to update it to also support whitespaces in paths ("Application<whitespace>Support"):

Code: [Select]
- ^{#0:p}\:\s\bline\s{#1:i},\s\bcol\s{#2:i},\s{#3?+}$
+ ^{#0?+}\:\s\bline\s{#1:i},\s\bcol\s{#2:i},\s{#3?+}$

After these changes, I restarted SlickEdit, and since then, it has been working.  :)