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

fix linking of @bigtest/eslint-plugin rule to docs #804

Closed
wants to merge 3 commits into from
Closed
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
5 changes: 5 additions & 0 deletions .changeset/plenty-cycles-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigtest/eslint-plugin": patch
---

fix linking of @bigtest/eslint rule to docs
2 changes: 1 addition & 1 deletion packages/eslint-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ config file:

| Rule | Description | Configurations | Fixable |
| ---------------------------------------------------------------------------- | --------------------------------------------------------------- | ---------------- | ------------ |
| [require-default-export](docs/rules/require-default-test-export) | Each test file must have a default export.
| [@bigtest/require-default-export](docs/rules/require-default-export) | Each test file must have a default export.
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { requireDefaultTextExport } from './rules/require-default-export';

export const rules = {
'require-default-export': requireDefaultTextExport
'@bigtest/require-default-export': requireDefaultTextExport
};

export const configs = {
root: true,
recommended: {
rules: {
'bigtest/require-default-export': 2
'@bigtest/require-default-export': 2
}
}
}
17 changes: 13 additions & 4 deletions packages/eslint-plugin/src/rules/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ import {
ESLintUtils,
} from '@typescript-eslint/experimental-utils';
import path from 'path';
import { execSync } from 'child_process';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { version } = require('../../package.json');
const REPO_URL = 'https://github.com/thefrontside/bigtest';

const REPO_URL = 'https://github.com/thefrontside/bigtest/eslint-plugin';
export const getCurrentBranch = (): string => {
try {
return execSync('git branch --show-current', { timeout: 1000 }).toString().trim();
} catch (err) {
console.error(err);
throw err;
}
}

export const createRule = ESLintUtils.RuleCreator(name => {
let ruleName = path.parse(name).name;

return `${REPO_URL}/blob/v${version}/docs/rules/${ruleName}.md`;
let currentBranch = getCurrentBranch();

return `${REPO_URL}/blob/${currentBranch}/packages/eslint-plugin/docs/rules/${ruleName}.md`;
});