Skip to content

docs(eslint-plugin): change createRule usage to point to website #4369

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions packages/eslint-plugin/src/util/createRule.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { ESLintUtils } from '@typescript-eslint/experimental-utils';

// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const version: string = require('../../package.json').version;

export const createRule = ESLintUtils.RuleCreator(
name =>
`https://github.com/typescript-eslint/typescript-eslint/blob/v${version}/packages/eslint-plugin/docs/rules/${name}.md`,
name => `https://typescript-eslint.io/rules/${name}`,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bradzacher I have a vague memory of you mentioning it's preferable to link to the specific version of a rule, but can't find where that was. Did that opinion ever exist, and if so, is it still accurate now that the website is ready?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

back in the beginning it was a huge problem for us changing rules regularly.
Now-a-days everything is super stable so I don't think it's worth worrying about any more.

If we want to build it into the website - we totally could, but I think at this stage of the project it's probably super low value.

);
6 changes: 3 additions & 3 deletions packages/eslint-plugin/tests/docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ describe('Validating rule metadata', () => {
it('`name` field in rule must match the filename', () => {
// validate if rule name is same as url
// there is no way to access this field but its used only in generation of docs url
expect(
rule.meta.docs?.url?.endsWith(`rules/${ruleName}.md`),
).toBeTruthy();
expect(rule.meta.docs?.url).toBe(
`https://typescript-eslint.io/rules/${ruleName}`,
);
});

it('`requiresTypeChecking` should be set if the rule uses type information', () => {
Expand Down