GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — chore: remove kbd-scripts in favor of native linting config with ESlint by lwasser · Pull Request #402 · all-contributors/cli Conversation
|
| expect(error).toBeTruthy() | ||
| } | ||
|
|
||
| // TODO: Review whether to add explicit expect() or keep implicit assertion via helper |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Added some inline todos as I made some decisions here that I'd like to better understand! I don't know what best practices are in the JS world, but the {} seems like the modern way to "catch" an error without doing anything with it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It might be good to open an issue (whether or not there are these comments) so we can plan to revisit it later. I think it is fine to have an issue which isn't "ready to work", but you need to do some learning before deciding what needs to be done 👍.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the comment though 😅
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ok - let me circle back on this - an issue is definitely warranted here!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'll also try to make the issue more clear than my comments :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ok - i went back to my notes. Essentially, the eslint rule that was running with the kcd-scripts config was jest/expect-expect (node has some funny terms) 😆
which effectively meant that if a test didn't have an explicit expectation/assertion, it would raise a warning flag. But that's not always necessary. But if we left those old lint rules in place, we'd probably need to update the test. so i just flagged those tests to ignore that rule.
However, thanks to Joshua, we simplified the config and made it less opinionated, so we can remove all the comments and don't have to open an issue, as the linter is happy as is! AND we may move to vitest too so... jest rule won't even apply if that happens.
I think there were like 200 rules in the kcd-scripts config that I moved over. 🙃
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| }, | ||
| rules: { | ||
| // Custom overrides (from package.json eslintConfig) | ||
| camelcase: 'off', |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Here I took rules from Kent's repo and the tool had an LLM compare them to default settings, and removed overlap, and then asked the LLM to tell me which ones we may want to keep. I'm super open to what people think are best defaults, as I don't know Node well enough yet to have opinions. So this set of decisions is largely claude's! The original file with all the rules was 300+ lines.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yeah, old ESLint configs tend to be pretty intentional about a lot of things that they don't need to be. My general recommendation for migrating these old ones is to actually start from scratch and then add in rules when they come up. js.configs.recommended has come a long way since the days of kcd-scripts.
Suggestion: remove these "Custom overrides" and "Additional rules" sections altogether. Most of these are actually already set by the recommended config.
(I can give a deeper review later this week or so)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ok! after reading your blog I was going to ask you about that. today i started to look into some of the rules and i deleted maybe 2 dozen of them because they seemed overly opinionated. If we could just start with the default ESlint set i think that would be ideal but i'll wait for your deeper review
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Here's a clean start that removes roughly everything not turned on by default:
import js from '@eslint/js' import {defineConfig, globalIgnores} from 'eslint/config' import importPlugin from 'eslint-plugin-import' import jestPlugin from 'eslint-plugin-jest' import globals from 'globals' export default defineConfig([ globalIgnores(['coverage/**', 'dist/**']), {linterOptions: {reportUnusedDisableDirectives: 'error'}}, { extends: [js.configs.recommended, importPlugin.flatConfigs.recommended], files: ['**/*.{mjs,js}'], languageOptions: { ecmaVersion: 'latest', globals: globals.node, }, rules: { 'import/no-unresolved': ['error', {ignore: ['^eslint/']}], 'import/no-extraneous-dependencies': 'error', }, }, { extends: [jestPlugin.configs['flat/recommended']], files: ['**/__tests__/**/*.js'], languageOptions: { globals: globals.jest, }, rules: { 'jest/no-disabled-tests': 'error', 'jest/prefer-to-have-length': 'error', }, }, ])
A couple of notes:
import/no-unresolved line is annoying me. I griped about it here: https://bsky.app/profile/joshuakgoldberg.com/post/3mdfvvzvpfc27. tl;dr - a nested dependency doesn't yet support a new thing in Node.js that ESLint usesimport/no-extraneous-dependencies isn't on by default, but IMO is better caught by Knip. IMO that's a good followup to look into.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
thank you!! i will update the pr with your changes - always feel free to directly modify files in your reviews as well.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Just pushed up a new commit with this change. it's much simpler now!!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| import jestPlugin from 'eslint-plugin-jest' | ||
| import globals from 'globals' | ||
|
|
||
| export default [ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
For a better development time, ESLint now provides a defineConfig helper: https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file. It gives nice intellisense in IDEs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
cool lemme look into that @JoshuaKGoldberg what is the difference between
eslint.config.js
eslint.config.mjs
as in how would we decide which one to use?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ah what a good question. It's not an ESLint-specific thing, it's Node.js.
Glossing over some finer details, there are two "module" systems (syntax) we can use for importing & exporting between files:
module.exports.key = value;const { key } = require("./file");export const key = value;import { key } from "./file.js";ESM is generally a better syntax for a bunch of technical points. But for legacy reasons Node.js defaults to interpreting .js files as CJS. Node.js can be told to change that in two ways:
package.json, setting "type": "module switches the default to ESM.cjs or .mjs extension for a file switches the file to CJS or ESM, respectivelyAdding "type": "module" to the whole package is a bigger change, so a lot of projects use eslint.config.mjs in the interim.
Does that make sense?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the super clear explanation! It helps a lot. I have a followup question but i'll ask in an issue :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
eeks. i'll fix this tomorrow with fresh eyes. i may have undone some work with the rebase. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Looks good. A few comments, but it all seems to work well on my end 👍.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| expect(error).toBeTruthy() | ||
| } | ||
|
|
||
| // TODO: Review whether to add explicit expect() or keep implicit assertion via helper |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It might be good to open an issue (whether or not there are these comments) so we can plan to revisit it later. I think it is fine to have an issue which isn't "ready to work", but you need to do some learning before deciding what needs to be done 👍.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| expect(error).toBeTruthy() | ||
| } | ||
|
|
||
| // TODO: Review whether to add explicit expect() or keep implicit assertion via helper |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the comment though 😅
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Ok fantastic y'all. lemme know what else you'd like to see in this pr. I have a todo for myself to move the comments around tests to an issue. And I'll test out the ES Lint format on save config for vscode and will document it. Jim - to avoid too much confusion i thought we could
Let me know if that seems reasonable to you. This repo is a moving target right now 😆 it's very easy to break things because the deps are so dated and the API hasn't been updated in a few years. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I know this makes #412 pointless haha but I needed to update the lib to get further in the yargs update. Do we think this PR will get in before or is there more work to be done? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
That sounds very sensible 👍. No need to do that right away or block progress here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| import globals from 'globals' | ||
|
|
||
| export default defineConfig([ | ||
| globalIgnores(['coverage/**', 'dist/**', '_law_tests/**']), |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Where does the _law_tests directory come from?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
oh gosh darnit. I thought I had deleted that. That is a folder I have ignored globally on my computer, where I test things I don't even want to commit to Git. i had a dist/ folder in there from building that it kept finding. Let me remove that now. Good catch!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
ok! linter and test suite are both passing!! 🎉 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
@jdalrymple this PR should be good to merge. BUT I'm waiting on a maintainer to approve it - we have a one approval policy unless it's a major breaking change. 412 was good because it updated kcd-scripts, which will help us as we migrate other parts of the infra. But I hear you and apologize in advance if this happens again. The dependency spaghetti monster continues. How about i rebase this to a single commit in case you want to pull it down and work on top of it for the work you're doing? And then hopefully @JimMadge or @JoshuaKGoldberg will give it a green check soon!! ✨ I'll rebase right now as you don't need to pull down 15 commits. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Josh Goldberg ✨ <[email protected]>
Removed redundant lint-staged configuration and updated commands.
|
Hi Friends. If someone could review it and then I can merge it, I'd appreciate it. Essentially, I'm running into a lot of dependencies and merge conflicts because other PRs have been merged while this has been open for a long time. I just tried to rebase the branch and clean things up. But it was not pretty. If we can approve the merge, I'm happy to open the other issues we need to address about this specific change! but i can't handle any more merge and dependency conflicts on it as other things are merged ahead of it and i rebase 😆 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ok this should be ready to merge! Do we have a preference for merging strategy? I personally squash commit in my repos, but can do something fancier here if directed to. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
While I was in the area, I fixed up the Husky + lint-staged config. This should work to run lint-staged on precommits now.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thank you!!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
We decided to keep the original maintainers' squash merge policy! So let's do that here as well. I'll go ahead and merge this one now (before it gets larger!! 😆 ). But thank you again for the review and all of the input, help, etc!! It's awesome to be working with you here! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Oh, Jim and I have been approving PR's, and then sometimes we merge our own PR if there is an approving review. OR we approve and allow the author to merge. I'm fine with either or just both, as it makes sense. But i'm going to merge this just so I don't have to look at this branch again ever 😆 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
KCD Migration (ESlint): migrate to native ESlint
There was an error while loading. Please reload this page.