React Class functions - Can not generate JSdoc comment block

It seems that Webstorm doesn't know how to generate comments for ES6 class function syntax:

 

class App extends React.Component {

  myFunction(param1) {

 }

}

 

If I try to auto generate a comment block by typing '/**' and pressing enter, it does not work. Is there a way to enable this?

0
4 comments

Works fine for me:

it might be confused by some code below function declaration. Please can you provide a file that can be used to recreate the issue?

0
Avatar
Permanently deleted user

Hi,

 

Yes can try this function which seems to be problematic, I tried a few other places and your right it does work.

 

This function in any react class should have the issue

 

setVideos(data) {
let videos = [];
const SCORE_LIMIT = CLIENT === 'localhost' ? 7 : 25;
this.setState({ query: data.query });

if (data !== null && data.results && data.results.hits && data.results.hits.hit.length !== 0) {
console.log('DELTASTV: set videos', data);

data.results.hits.hit.slice(0, 4).forEach((video) => {
let keywordsMatched = [];
const highlights = video.highlights;
const fields = video.fields;
const regex = /\*(\S[\s\S]*?)\*/g;

// grab all highlighted keywords
if (CLIENT === 'localhost') {
keywordsMatched = keywordsMatched
.concat(highlights.extra_one.match(regex) || [])
.concat(highlights.description.match(regex) || [])
.concat(highlights.keywords.match(regex) || [])
.concat(highlights.thumbnail_alt.match(regex) || [])
.concat(highlights.thumbnail_alt_small.match(regex) || []);

} else {
keywordsMatched = keywordsMatched
.concat(highlights.descriptions_default.match(regex) || [])
.concat(highlights.descriptions_long.match(regex) || [])
.concat(highlights.title.match(regex) || [])
.concat(highlights.slug.match(regex) || [])
.concat(highlights.thumbnails_large_alttext.match(regex) || [])
.concat(highlights.thumbnails_small_alttext.match(regex) || [])
.concat(highlights.published.match(regex) || []);
}

// deduplicate array
const uniqueKeywords = [];
keywordsMatched
.map(k => k.toLowerCase())
.forEach((k) => {
if (uniqueKeywords.indexOf(k) === -1) uniqueKeywords.push(k);
});

if (Number(fields._score[0]) > SCORE_LIMIT && uniqueKeywords.length >= 1) {
videos.push({
sources: [{
src: CLIENT === 'localhost' ? fields.video_url[0] : fields.videos_hd_uri[0],
type: 'video/mp4',
}],
poster: CLIENT === 'localhost' ? fields.thumbnail_url[0] : fields.thumbnails_large_src[0],
title: CLIENT === 'localhost' ? fields.extra_one[0] : fields.title[0],
});
}
});

if (videos.length !== 0) {
console.log('DELTASTV: videos arr [actual] ', videos);
this.setState({
videos,
videoss: 'search',
});
} else {
console.log('DELTASTV: none of the videos matched enough keywords or have big enough score');
setDefaultClientVideos(this);
}
} else {
setDefaultClientVideos(this);
}

function setDefaultClientVideos(ctx) {
videos = ctx.state.spectator;
if (CLIENT === 'localhost') videos = ctx.state.localhost;

ctx.setState({
videos,
videoss: 'defaultplaylist',
});
}
}

 

 

0

I see, thanks:) Problem is caused by "*/"  in regexp, please follow https://youtrack.jetbrains.com/issue/WEB-21158 for updates

0
Avatar
Permanently deleted user

Ah ok great thank you

0

Please sign in to leave a comment.