Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gajus/eslint-plugin-jsdoc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v38.1.5
Choose a base ref
...
head repository: gajus/eslint-plugin-jsdoc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v38.1.6
Choose a head ref
  • 2 commits
  • 7 files changed
  • 1 contributor

Commits on Apr 2, 2022

  1. fix(no-restricted-syntax, no-missing-syntax): pass on parser's `v…

    …isitorKeys` to esquery
    
    Also:
    - test(`no-restricted-syntax`): use custom parser to include JsdocBlock reference in main `context`
    brettz9 committed Apr 2, 2022
    Copy the full SHA
    f873e32 View commit details
  2. Copy the full SHA
    1c9884d View commit details
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
"@babel/plugin-transform-flow-strip-types": "^7.16.7",
"@babel/preset-env": "^7.16.11",
"@babel/register": "^7.17.7",
"@es-joy/jsdoc-eslint-parser": "^0.8.2",
"@hkdobrev/run-if-changed": "^0.3.1",
"@typescript-eslint/parser": "^5.17.0",
"babel-plugin-add-module-exports": "^1.0.4",
1 change: 0 additions & 1 deletion src/iterateJsdoc.js
Original file line number Diff line number Diff line change
@@ -1271,7 +1271,6 @@ export default function iterateJsdoc (iterator, ruleConfig) {

const checkJsdoc = (info, handler, node) => {
const jsdocNode = getJSDocComment(sourceCode, node, settings);

if (!jsdocNode) {
return;
}
5 changes: 1 addition & 4 deletions src/rules/checkParamNames.js
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ import iterateJsdoc from '../iterateJsdoc';
* @param {boolean} enableFixer
* @param {Array<string>} functionParameterNames
* @param jsdoc
* @param _jsdocNode
* @param utils
* @param report
* @returns {boolean}
@@ -23,7 +22,7 @@ const validateParameterNames = (
checkTypesRegex,
disableExtraPropertyReporting,
enableFixer,
functionParameterNames, jsdoc, _jsdocNode, utils, report,
functionParameterNames, jsdoc, utils, report,
) => {
const paramTags = Object.entries(jsdoc.tags).filter(([
, tag,
@@ -297,7 +296,6 @@ const validateParameterNamesDeep = (
export default iterateJsdoc(({
context,
jsdoc,
jsdocNode,
report,
utils,
}) => {
@@ -332,7 +330,6 @@ export default iterateJsdoc(({
enableFixer,
functionParameterNames,
jsdoc,
jsdocNode,
utils,
report,
);
5 changes: 1 addition & 4 deletions src/rules/checkPropertyNames.js
Original file line number Diff line number Diff line change
@@ -4,14 +4,13 @@ import iterateJsdoc from '../iterateJsdoc';
* @param {string} targetTagName
* @param {boolean} enableFixer
* @param jsdoc
* @param jsdocNode
* @param utils
* @returns {boolean}
*/
const validatePropertyNames = (
targetTagName,
enableFixer,
jsdoc, jsdocNode, utils,
jsdoc, utils,
) => {
const propertyTags = Object.entries(jsdoc.tags).filter(([
, tag,
@@ -95,7 +94,6 @@ const validatePropertyNamesDeep = (
export default iterateJsdoc(({
context,
jsdoc,
jsdocNode,
report,
utils,
}) => {
@@ -114,7 +112,6 @@ export default iterateJsdoc(({
targetTagName,
enableFixer,
jsdoc,
jsdocNode,
utils,
);

9 changes: 7 additions & 2 deletions src/rules/noMissingSyntax.js
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ export default iterateJsdoc(({
info: {
comment,
},
sourceCode,
state,
}) => {
if (!context.options[0]) {
@@ -38,8 +39,12 @@ export default iterateJsdoc(({

const foundContext = contexts.find((cntxt) => {
return typeof cntxt === 'string' ?
esquery.matches(node, esquery.parse(cntxt)) :
(!cntxt.context || cntxt.context === 'any' || esquery.matches(node, esquery.parse(cntxt.context))) &&
esquery.matches(node, esquery.parse(cntxt), null, {
visitorKeys: sourceCode.visitorKeys,
}) :
(!cntxt.context || cntxt.context === 'any' || esquery.matches(node, esquery.parse(cntxt.context), null, {
visitorKeys: sourceCode.visitorKeys,
})) &&
comment === cntxt.comment;
});

9 changes: 7 additions & 2 deletions src/rules/noRestrictedSyntax.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ export default iterateJsdoc(({
info: {
comment,
},
sourceCode,
report,
}) => {
if (!context.options.length) {
@@ -21,8 +22,12 @@ export default iterateJsdoc(({

const foundContext = contexts.find((cntxt) => {
return typeof cntxt === 'string' ?
esquery.matches(node, esquery.parse(cntxt)) :
(!cntxt.context || cntxt.context === 'any' || esquery.matches(node, esquery.parse(cntxt.context))) &&
esquery.matches(node, esquery.parse(cntxt), null, {
visitorKeys: sourceCode.visitorKeys,
}) :
(!cntxt.context || cntxt.context === 'any' || esquery.matches(node, esquery.parse(cntxt.context), null, {
visitorKeys: sourceCode.visitorKeys,
})) &&
comment === cntxt.comment;
});

25 changes: 25 additions & 0 deletions test/rules/assertions/noRestrictedSyntax.js
Original file line number Diff line number Diff line change
@@ -347,6 +347,31 @@ export default {
},
],
},
{
code: `
class a {
/** */
private b () {}
}
`,
errors: [
{
line: 3,
message: 'Syntax is restricted: MethodDefinition:not([accessibility="public"]):has(JsdocBlock)',
},
],
ignoreReadme: true,
options: [
{
contexts: [
{
context: 'MethodDefinition:not([accessibility="public"]):has(JsdocBlock)',
},
],
},
],
parser: require.resolve('@es-joy/jsdoc-eslint-parser/typescript'),
},
],
valid: [
{