Skip to content

Commit

Permalink
fix: with fixers, create proper inner indent (of an additional space)…
Browse files Browse the repository at this point in the history
… when a tab is in use; fixes #607
  • Loading branch information
brettz9 committed Jul 9, 2020
1 parent 1842fd2 commit 4dfbc8d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -10996,6 +10996,16 @@ module.exports = class GraphQL {
};
// Options: [{"checkRestProperty":true}]
// Message: Missing JSDoc @param "fetchOptions.url" declaration.

(function() {
/**
* A function.
*/
function f(param) {
return !param;
}
})();
// Message: Missing JSDoc @param "param" declaration.
````

The following patterns are not considered problems:
Expand Down
2 changes: 1 addition & 1 deletion src/jsdocUtils.js
Expand Up @@ -767,7 +767,7 @@ const getTagsByType = (context, mode, tags, tagPreference) => {

const getIndent = (sourceCode) => {
let indent = sourceCode.text.match(/^\n*([ \t]+)/u);
indent = indent ? indent[1] + indent[1].charAt() : ' ';
indent = indent ? indent[1] + ' ' : ' ';

return indent;
};
Expand Down
30 changes: 30 additions & 0 deletions test/rules/assertions/requireParam.js
Expand Up @@ -1928,6 +1928,36 @@ export default {
`,
parser: require.resolve('babel-eslint'),
},
/* eslint-disable no-tabs */
{
code: `
(function() {
/**
* A function.
*/
function f(param) {
return !param;
}
})();
`,
errors: [
{
message: 'Missing JSDoc @param "param" declaration.',
},
],
output: `
(function() {
/**
* A function.
* @param param
*/
function f(param) {
return !param;
}
})();
`,
/* eslint-enable no-tabs */
},
],
valid: [
{
Expand Down

0 comments on commit 4dfbc8d

Please sign in to comment.