Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use module.parent for resolving rule name #188

Merged
merged 1 commit into from
Feb 15, 2018

Conversation

sudo-suhas
Copy link
Contributor

module.parent is cached after the first require and this results in nearly all rules having the URL to assertion-arguments. Here's a simple repro:

'use strict';

const { rules } = require('eslint-plugin-ava');

const wrongLinks = [];

for (const ruleName of Object.keys(rules)) {
    const rule = rules[ruleName];
    const { url } = rule.meta.docs;
    if (!url.includes(ruleName)) wrongLinks.push(ruleName);
}

console.log(wrongLinks);
λ node rule-docs-url.js
[ 'max-asserts',
  'no-async-fn-without-await',
  'no-cb-test',
  'no-duplicate-modifiers',
  'no-identical-title',
  'no-ignored-test-files',
  'no-invalid-end',
  'no-nested-tests',
  'no-only-test',
  'no-skip-assert',
  'no-skip-test',
  'no-statement-after-end',
  'no-todo-implementation',
  'no-todo-test',
  'no-unknown-modifiers',
  'prefer-async-await',
  'prefer-power-assert',
  'test-ended',
  'test-title',
  'use-t-well',
  'use-t',
  'use-test',
  'use-true-false' ]

Credits to @SimenB for calling this out in jest-community/eslint-plugin-jest@e0160e5#r27576164.

`modeule.parent` is cached after the first `require` and this results in nearly
all rules having the URL to `assertion-arguments`.
@sindresorhus sindresorhus merged commit c5903fd into avajs:master Feb 15, 2018
@sindresorhus
Copy link
Member

@sudo-suhas
Copy link
Contributor Author

Sure, will do it by tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants