Replace eslint rulesdir with eslint-plugin-local, convert eslint rules to JS#50380
Replace eslint rulesdir with eslint-plugin-local, convert eslint rules to JS#50380jakebailey merged 18 commits intomicrosoft:mainfrom
Conversation
|
The only gotcha here is that people working on branches between these two configs may get an error in their editor, depending on which config they have in |
| const { createRule } = require("./utils"); | ||
|
|
||
| export = createRule({ | ||
| module.exports = createRule({ |
There was a problem hiding this comment.
These are all now CJS (well, they were before after compilation, but now we're hand-writing that); a future version of ESLint is poised to completely revamp the way that configuration works and will likely enable ESM rules.
eslint-local-rules.js
Outdated
| const ext = ".js"; | ||
| const ruleFiles = fs.readdirSync(rulesDir).filter((p) => p.endsWith(ext)); | ||
|
|
||
| module.exports = Object.fromEntries(ruleFiles.map((p) => { |
There was a problem hiding this comment.
Is this a magic filename for the plugin?
There was a problem hiding this comment.
eslint-local-rules.js is, yeah. Unfortunately, it doesn't allow you to use a dotted name. You can have eslint-local-rules.js or eslint-local-rules/index.js, and that's it.
I could switch to https://github.com/taskworld/eslint-plugin-local, which has more downloads is literally just module.exports = require('../../.eslintplugin'), a better filename.
There was a problem hiding this comment.
Switched it; it hasn't been updated in 5 years but when it's so simple... :D
| .yarnrc | ||
| tmp | ||
| .eslintplugin.js | ||
| .eslintcache |
There was a problem hiding this comment.
I should have included this on my eslint-at-root PR; I really dislike npmignore for this reason. Maybe I'll sit down and change our package to use "files" instead.
| // Rename this file 'settings.json' or merge its | ||
| // contents into your existing settings. | ||
| { | ||
| "eslint.validate": [ |
There was a problem hiding this comment.
With this gone, the template consists solely of suggestions for typescript.tsdk values.
|
Should should be ready for review; I don't think I have any other changes. |
--rulesdiris deprecated in favor of plugins. Although there's no official support for a local plugin,eslint-plugin-localcan do what we need. This, combined with converting our rules to JS, means that we don't need any configuration in VS Code or to run the CLI, nor do we need a build step to run after clone or branch changes (leaving the diagnostics as the only remaining build step on clone/branch change).