Comments (5)
Duplicate of #5017, #6967, #7944, #8258.
from typescript-eslint.
@matthieusieben: ts-eslint models the "TypeScript language" part of typescript
. There's also a "JavaScript linting" part of typescript
which includes JSDoc and lots of heuristic-based inference to make "idiomatic JS" work without any rewriting. We never explicitly have support for this part. Similarly, TypeScript has cross-module checking features, but we don't, because it's delegated to eslint-plugin-import
. For JSDoc, you would want to use eslint-plugin-jsdoc
instead.
from typescript-eslint.
JSDoc is not real code
JSDoc is a very, very loosely defined spec for how it works. It's not even really a spec - it's more of a convention. There's a lot of ambiguity in it and TS does not enforce that you write it in a specific way - it just loosely handles the comments as best it can.
When we parse TS code we use TS's parser. Code is well defined with a grammar and there's little ambiguity (there is technically some but the TS parser handles and hides that ambiguity) and we get one concrete AST representation for the file. We don't need to worry about problems like "what if someone provides two return type annotations?" Cos you cannot provide two return type annotations on a function that's a syntax error to even try it.
OTOH JSDoc comments do not have the same concrete representation.
For example this is a valid annotation:
/**
* @returns {string}
* @returns {number}
* @return {boolean}
* @return {null}
*/
What does it mean? Who knows really - the interpretation is left up to the consumer.
For TS it will error on this comment and mark the last 3 as an error with 'returns' tag already specified
. However TS emits a JSDoc AST for this and that AST contains FOUR JSDocReturnTag
nodes.
So you can see how this gets complicated - what do we do here? Well we have to research and understand exactly how JSDoc is handled by TS internally so that we can model that exact same behaviour. That means every TS release we also need to review TS's JSDoc handling again to determine if anything changed.
It's a huge maintenance burden for us as volunteer maintainers.
So instead we have chosen to not handled JSDoc at all and instead, as Josh mentioned, we tell people to use eslint-plugin-jsdoc
which is built in its own way with its own rules and parser for handling JSDoc.
I.e. instead of us trying to understand JSDoc ourselves whilst we're working to understand TS - we leave that responsibility to a separate project which has the knowledge and resources that can do that. This separation of concerns creates a higher quality result with less stress/burden on any one group and is a core tenet of how the ESLint ecosystem has evolved and grown.
I definitely understand the reason behind wanting this - but ultimately it's a very niche usecase within the TypeScript ecosystem. A very, very small fraction of people annotate JSDoc this way.
Which is why it's not worth us as bandwidth-limited, volunteer maintainers to dedicate time to supporting this. The cost:value ratio isn't there for us when eslint-plugin-jsdoc
is there for people to opt-in to support these usecases.
from typescript-eslint.
Is there any chance to re-consider this ? I get that @bradzacher thinks "JSDoc is not real code" but the typescript compiler actually disagrees with this. It is a shame that typescript-eslint
does not follow the conventions abopted typescript
...
from typescript-eslint.
Thanks for the detailed explanation. These tools are so complicated to get working (e.g. one would assume that typescript-eslint is on par feature wise with typescript), I find it a missed opportunity. But that's just me (and probably a few other from those other issues). Thanks for your work anyways.
from typescript-eslint.
Related Issues (20)
- Enhancement: [naming-convention] Add an optional identifier member of each option HOT 1
- Bug: [no-inferrable-types] False positive with default parameter in closure passed to generic function HOT 1
- Repo (eslint-plugin) [consistent-type-assertions] test case missing output assertion
- Try out v8 beta on various important community repos HOT 4
- Bug: ESlint v9 server does lint in typescript monorepo HOT 5
- Repo: Weekly release flow is failing on changelogRenderer again HOT 5
- Bug: no-magic-numbers Doesn't apply ignore to type definitions HOT 5
- Enhancement: [prefer-nullish-coalescing] Ignore env vars HOT 1
- Enhancement: [no-useless-template-literals] Delete in v8
- Bug: Missing `src/util` import in `@typescript-eslint/eslint-plugin@rc-v8` with skipLibCheck: false HOT 1
- Enhancement: [prefer-literal-enum-member] Allow nested bitwise when using the `allowBitwiseExpressions` option HOT 5
- Enhancement: [no-non-null-assertion] Optionally exempt contexts where null would immediately throw at runtime HOT 12
- Bug: incorrect peer dependency "eslint@^8.56.0" HOT 2
- Bug: [explicit-function-return-type] false invalid case when using allowTypedFunctionExpressions option HOT 5
- Enhancement: [await-thenable] Should check chained method calls HOT 2
- Bug: @typescript-eslint/no-unused-vars false positive when using "using" declaration statement HOT 7
- 🐛 Bug: RuleTester updates reverted in v8 branch HOT 2
- Bug: [prefer-nullish-coalescing] should consider the difference between null and undefined with strict equality HOT 2
- Bug: 8.0.0.alpha24 shared configuration with type checking fail to start HOT 1
- Bug: `no-floating-promises` should not fire on `Promise.resolve()` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript-eslint.