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

Support Node10 #56

Open
krassowski opened this issue Aug 29, 2020 · 2 comments
Open

Support Node10 #56

krassowski opened this issue Aug 29, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@krassowski
Copy link
Contributor

krassowski commented Aug 29, 2020

When being used with sqlite3. Some diagnostics do work (Expected "--", "/*", "FROM", "GROUP", "LIMIT", "ORDER", "UNION", "WHERE", [ \t\n\r], or end of input but "X" found.) but most frequently it just throws this error.

TypeError: diagnostics.concat(...).flat is not a function
    at rules.forEach (/home/krassowski/jupyterlab-lsp/node_modules/sqlint/dist/src/rules/index.js:68:60)
    at Array.forEach (<anonymous>)
    at apply (/home/krassowski/jupyterlab-lsp/node_modules/sqlint/dist/src/rules/index.js:46:11)
    at walk (/home/krassowski/jupyterlab-lsp/node_modules/sqlint/dist/src/rules/index.js:77:38)
    at Object.values.forEach (/home/krassowski/jupyterlab-lsp/node_modules/sqlint/dist/src/rules/index.js:79:23)
    at Array.forEach (<anonymous>)
    at walk (/home/krassowski/jupyterlab-lsp/node_modules/sqlint/dist/src/rules/index.js:78:25)
    at Object.execute (/home/krassowski/jupyterlab-lsp/node_modules/sqlint/dist/src/rules/index.js:32:12)
    at Object.lint (/home/krassowski/jupyterlab-lsp/node_modules/sqlint/dist/src/cli/lint.js:52:53)
    at doLint (/home/krassowski/jupyterlab-lsp/node_modules/sql-language-server/dist/src/createDiagnostics.js:16:40)

This happens at:

diagnostics = diagnostics.concat(_diagnostics).flat();

The example _diagnostics content is:

[ { location: { start: [Object], end: [Object] },
    message: 'A linebreak is required after SELECT keyword',
    errorLevel: 2,
    fix: [ [Object], [Object] ],
    rulename: 'linebreak-after-clause-keyword' } ]

The diagnostics is just an empty array: [].

[].concat([{ message: 'A linebreak is required after SELECT keyword'}])

results in:

[{ message: 'A linebreak is required after SELECT keyword'}]

which does not have the flat() method in the node 10.

So the only problem is that the required runtime it Node 11+, but it is not specified in readme I guess... Or maybe the concat().flat() could be replaced with push() and spread operator?

@joe-re
Copy link
Owner

joe-re commented Aug 30, 2020

@krassowski Hi, thank you for your report.
I'll have a plan to deal with node 10.

@joe-re joe-re added the enhancement New feature or request label Aug 30, 2020
@joe-re joe-re changed the title Sqlint throws an error on diagnostics.concat(...).flat Support Node10 Aug 30, 2020
@otreblan
Copy link

It also happens with node 14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants