Support Node10
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?
@krassowski Hi, thank you for your report. I'll have a plan to deal with node 10.
It also happens with node 14.