obsidian-sample-plugin icon indicating copy to clipboard operation
obsidian-sample-plugin copied to clipboard

Update packages, eslint, and fix missing packages.

Open stroiman opened this issue 1 year ago • 6 comments

This update outdated packages, updates eslint, and adds a few missing packages

Fix missing packages

Build tools, like eslint, should be added as dev dependencies to JS projects. Then it's the concrete version in your project used when building; rather than depending on an uncontrollable context; which plugins developers or build servers have installed globally.

Update eslint

The .eslintrc format is obsolete. It has been updated to the new flat file format

Update packages

Many packages were very old; including TypeScript that was at 4.x.

Eslint is only updated to version 8; rather than 9 - because the typescript eslint module doesn't support eslint@8 as a peer dependency; making npm fail during install.

@types/node should be of the same major version as the actual node.js runtime. In my local Obsidian developer console, process.versions reveals that it uses version 18 (not 20?), which is why I updated that module to version 18.

stroiman avatar Aug 02 '24 12:08 stroiman

The oldest node version that a user can run, and still have a supported installer version is 16.13.2 You also have listed @types/node twice

And when using typescript-eslint one should not use the JS presets, since they overlap somewhat.

joethei avatar Aug 02 '24 13:08 joethei

Allright, I rolled back the @types/node update

But it is correct that Obsidian comes bundled with a version of node.js? Is there an overview which Obsidian versions use which node versions? E.g. if I decided to use a feature that only exists in node 18, I should make sure that my minAppVersion is set accordingly. (hypothetical right now - not something I have any plans of)

I'll take a look at the eslint settings later today, but I didn't write the configuration; I just used the migration tool to migrate the existing config from the original tempalte.

> npx @eslint/migrate-config .eslintrc.json

As documented here: https://eslint.org/docs/latest/use/configure/migration-guide

That also mentioned that I needed the other eslint packages, that I added.

stroiman avatar Aug 05 '24 08:08 stroiman

The Obsidian installer comes bundled with Electron & Node, among other things. The app version is seperate from that, and thus minAppVersion can't be used to make sure a specific Node.js version is installed.

See also: https://help.obsidian.md/Getting+started/Update+Obsidian#Installer+updates

joethei avatar Aug 05 '24 13:08 joethei

Allright, a bit of searching made me understand the steps in the auto-converted file does; as well that there's a new typescript plugin compatible with the flat format, simplifying the configuration; and removing the necessity for some of the added packages.

Seems to work, i.e. linter errors are generated when I deliberately create them; both in my editor; and from command line. I'll take the modified config for a spin in my WIP plugin project.

Btw, maybe it would make sense to include a 'lint' step in the 'build' script?

stroiman avatar Aug 05 '24 14:08 stroiman

The Obsidian installer comes bundled with Electron & Node, among other things. The app version is seperate from that, and thus minAppVersion can't be used to make sure a specific Node.js version is installed.

See also: https://help.obsidian.md/Getting+started/Update+Obsidian#Installer+updates

there was a breaking change once that requires a minimum client version to receive updates. it's definitely a newer target than ES6. ES2018 is safe as far as I know because of that. feel free to ask around but unless you want to write plugins that target EOL obsidian versions, I'd say this argument doesn't really work. Especially since there is actual performance improvements since then in the target js version. for example.. classes have properties now.. various prototypes in core js no longer need polyfills etc.

GottZ avatar Dec 04 '24 14:12 GottZ

Yes, that happens every now and then. The last time this happened was Obsidian 0.14.5, the Electron version at that time was 18.0.3 and the Node version corresponding to that is 16.13.2. See this file: https://github.com/obsidianmd/obsidian-releases/blob/master/desktop-releases.json. The minimumVersion there is what we still support as the installer version.

And there are certainly users using installer versions that old.

joethei avatar Dec 04 '24 15:12 joethei