feat: add restrict-plus-operands#129
Conversation
|
Will fix CI |
|
I do not like this change for various reasons... The only thing I can think to do is turn this into a mini mono-repo with a nested project within Otherwise, as it stands users of this package will get this dependencies installed automatically, which isn't ideal because some node-only projects will not want vue as a dev dep. I think I'll probably refactor this, but just wanted to get out a working version and then see what you thought @onebytegone |
| @@ -1,57 +1,60 @@ | |||
| { | |||
| "name": "@silvermine/eslint-config", | |||
There was a problem hiding this comment.
Formats to 3 spaces (like some other repos)... Not really supposed to be included in this PR but I added here anyway
| "typescript": "5.8.3", | ||
| "@silvermine/typescript-config": "github:silvermine/typescript-config#ea8b79237aee970a15ab85beedf8e524478ef671", | ||
| "vue": "3.5.18", | ||
| "@vue/tsconfig": "0.7.0" |
There was a problem hiding this comment.
Notable changes lines 48-50
|
This See https://typescript-eslint.io/getting-started/typed-linting/ |
I haven't looked at this closely enough to understand the overarching issue that you're suggesting the monorepo for, but just wanted to point out that any package that uses this package shouldn't get Vue because it's a devDependency, in case that helps. |
Honestly kind of blanked and forgot devDeps don't get inherited. Think this PR should be OK to merge as is then? |
|
Consumers of this update will need to add this to their eslint config if they do not already have it. Don't know how we'd want to document this breaking change -- but notable here. {
// eslint.config.js
...
files: [ '**/*.ts' ],
languageOptions: {
parserOptions: {
project: 'tsconfig.json', // <----- THIS LINE
},
},
...
} |
2a18d14 to
1d01d40
Compare
|
Alright, I've added the readme.md examples as well as the update to the commit message, please have a look over them. Should be good to merge now @yokuze |
README.md
Outdated
| ...config, | ||
| { | ||
| files: [ '**/*.ts' ], | ||
| ...config, |
There was a problem hiding this comment.
It looks like the target of the ...config spread moved from the array to an object that's surrounding all of the config properties. Also, there's a syntax error: The { ...typescript block is nested within that object, but without a key.
There was a problem hiding this comment.
Which makes me think that with these extra levels of nesting the spread syntax approach is just a bit too onerous now.
Could you look at how we may be able to use ESLint's extend property instead? Maybe something like:
[
{
files: [ '**/*.ts' ],
languageOptions: {
parserOptions: {
project: './tsconfig.node.json',
},
},
extends: [ typescript ],
}
]? Not sure - you'd have to check that ESLint merges the config keys/values in the way that would make that work without blowing away the other languageOptions, for example.
There was a problem hiding this comment.
Hey, sorry about misaligned spread syntax. Resolved that issue on latest change. Also simplified the example as, like you said, it's a bit onerous.
Tested on another large repo with my forked commit hash. Tested working as presented in this example as well as a few other configuration options that are more involved.
Regarding the extends key, it's been deprecated/removed in v9, only enabled via some compat functions. Now that this example has been simplified to only highlight the necessary changes, I think we'll be fine to leave as-is for now and return to this issue when we upgrade to eslint v9.
Oops! Something went wrong! :(
ESLint: 8.57.1
A config object is using the "extends" key, which is not supported in flat config system.
Instead of "extends", you can include config objects that you'd like to extend from directly in the flat config array.
Please see the following page for more information:
https://eslint.org/docs/latest/use/configure/migration-guide#predefined-and-shareable-configs
README.md
Outdated
| Notice that we must specify the `project` property within `languageOptions.parserOptions` | ||
| to enable TypeScript strongly typed linting. | ||
|
|
||
| Below is an example of using Vue 3 with TypeScript: |
There was a problem hiding this comment.
There's a "Vue Support" heading below - it seems like this belongs there, especially now that it's required config for Vue.
There was a problem hiding this comment.
Thanks for catching. I moved all of the Vue related config notes within the Vue subheading.
README.md
Outdated
| vue = require('@silvermine/eslint-config/partials/vue'); | ||
|
|
||
| module.exports = [ | ||
| { |
There was a problem hiding this comment.
Same issue here with the top-level { }
There was a problem hiding this comment.
Resolved this as well. Thanks
1d01d40 to
7d51c9b
Compare
This enables strongly typed checking within the current project. Consumers of this repo will need to be sure they pass languageOptions.parserOptions.project, which points to their tsconfig file to enable type checking rules.
7d51c9b to
693ba3e
Compare
https://typescript-eslint.io/rules/restrict-plus-operands/