Skip to content

chore(deps): update dependency husky to v7 #1127

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 2 commits into from
Jul 3, 2021
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
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run precommit
15,930 changes: 7,965 additions & 7,965 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,13 @@
"babel-jest": "27.0.6",
"eslint": "7.30.0",
"eslint-plugin-simple-import-sort": "7.0.0",
"husky": "6.0.0",
"husky": "^7.0.0",
"jest": "27.0.6",
"lint-staged": "11.0.0",
"prettier": "2.3.2",
"strip-ansi": "6.0.0"
},
"homepage": "https://github.com/typescript-eslint/tslint-to-eslint-config#readme",
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"keywords": [
"eslint",
"tslint",
Expand All @@ -71,6 +66,8 @@
},
"scripts": {
"eslint": "eslint \"./src/*.ts\" \"./src/**/*.ts\" --report-unused-disable-directives",
"precommit": "lint-staged",
"prepare": "husky install",
"prettier": "prettier \"./src/*.{js,json,ts,xml,yaml}\" \"./src/**/*.{js,json,ts,xml,yaml}\" --ignore-path .prettierignore",
"prettier:write": "npm run prettier -- --write",
"test": "jest",
Expand Down
7 changes: 4 additions & 3 deletions src/converters/comments/parseFileComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ export const parseFileComments = (filePath: string, content: string) => {
const tslintRegex = new RegExp(/tslint:(enable|disable)(?:-(line|next-line))?(:|\s|$)/g);

const parseFileComment = (fullText: string, comment: ts.CommentRange): FileComment | undefined => {
const commentText = (comment.kind === ts.SyntaxKind.SingleLineCommentTrivia
? fullText.substring(comment.pos + 2, comment.end)
: fullText.substring(comment.pos + 2, comment.end - 2)
const commentText = (
comment.kind === ts.SyntaxKind.SingleLineCommentTrivia
? fullText.substring(comment.pos + 2, comment.end)
: fullText.substring(comment.pos + 2, comment.end - 2)
).trim();
const match = commentText.match(tslintRegex);
if (match === null) {
Expand Down
6 changes: 3 additions & 3 deletions src/converters/lintConfigs/formatConvertedRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export const formatConvertedRules = (
tslintConfiguration: TSLintConfiguration,
) => {
const output: Record<string, string | any[]> = {};
const sortedRuleEntries = Array.from(
conversionResults.converted,
).sort(([ruleNameA], [ruleNameB]) => ruleNameA.localeCompare(ruleNameB));
const sortedRuleEntries = Array.from(conversionResults.converted).sort(
([ruleNameA], [ruleNameB]) => ruleNameA.localeCompare(ruleNameB),
);

for (const [ruleName, rule] of sortedRuleEntries) {
output[ruleName] = formatConvertedRule(rule);
Expand Down
5 changes: 3 additions & 2 deletions src/converters/lintConfigs/rules/ruleConverters/no-cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export const convertNoCookies: RuleConverter = () => {
ruleArguments: [
{
message: "Forbidden call to document.cookie",
selector: 'MemberExpression[object.name="document"][property.name="cookie"]',
}
selector:
'MemberExpression[object.name="document"][property.name="cookie"]',
},
],
ruleName: "restricted-syntax",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ export const convertNoDocumentDomain: RuleConverter = () => {
{
ruleArguments: [
{
message: 'Forbidden write to document.domain.',
selector: 'AssignmentExpression[left.type="MemberExpression"][left.object.name="document"][left.property.name="domain"]',
message: "Forbidden write to document.domain.",
selector:
'AssignmentExpression[left.type="MemberExpression"][left.object.name="document"][left.property.name="domain"]',
},
{
message: 'Forbidden write to document.domain.',
selector: 'AssignmentExpression[left.type="MemberExpression"][left.object.type="MemberExpression"][left.object.object.name="window"][left.object.property.name="document"][left.property.name="domain"]',
message: "Forbidden write to document.domain.",
selector:
'AssignmentExpression[left.type="MemberExpression"][left.object.type="MemberExpression"][left.object.object.name="window"][left.object.property.name="document"][left.property.name="domain"]',
},
],
ruleName: "no-restricted-syntax",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ export const convertNoDocumentWrite: RuleConverter = () => {
{
ruleArguments: [
{
message: 'Forbidden call to document.write.',
selector: 'CallExpression[callee.type="MemberExpression"][callee.object.name="document"][callee.property.name=/^(write|writeln)$/]',
message: "Forbidden call to document.write.",
selector:
'CallExpression[callee.type="MemberExpression"][callee.object.name="document"][callee.property.name=/^(write|writeln)$/]',
},
{
message: 'Forbidden write to document.write.',
selector: 'CallExpression[callee.type="MemberExpression"][callee.object.type="MemberExpression"][callee.object.object.name="window"][callee.object.property.name="document"][callee.property.name=/^(write|writeln)$/]',
message: "Forbidden write to document.write.",
selector:
'CallExpression[callee.type="MemberExpression"][callee.object.type="MemberExpression"][callee.object.object.name="window"][callee.object.property.name="document"][callee.property.name=/^(write|writeln)$/]',
},
],
ruleName: "no-restricted-syntax",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const convertNoExecScript: RuleConverter = () => {
{
message: "Forbidden call to execScript",
selector: 'CallExpression[callee.name="execScript"]',
}
},
],
ruleName: "restricted-syntax",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { RuleConverter } from "../ruleConverter";

export const convertReactA11yAccessibleHeadings: RuleConverter = (tslintRule) => {
return {
...tslintRule.ruleArguments.length === 1 && { notices: ["jsx-a11y/heading-has-content rule does not support maxHeadingLength"] },
...(tslintRule.ruleArguments.length === 1 && {
notices: ["jsx-a11y/heading-has-content rule does not support maxHeadingLength"],
}),
plugins: ["jsx-a11y"],
rules: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { RuleConverter } from "../ruleConverter";

export const convertReactA11yAnchors: RuleConverter = (tslintRule) => {
return {
...(tslintRule.ruleArguments.length > 0 && ({
notices: Object.keys(tslintRule.ruleArguments[0] as Record<string, unknown>).map(key => `jsx-a11y/anchor-is-valid does not support the '${key}' option.`)
})),
...(tslintRule.ruleArguments.length > 0 && {
notices: Object.keys(tslintRule.ruleArguments[0] as Record<string, unknown>).map(
(key) => `jsx-a11y/anchor-is-valid does not support the '${key}' option.`,
),
}),
plugins: ["jsx-a11y"],
rules: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { RuleConverter } from "../ruleConverter";

export const convertReactNoDangerousHtml: RuleConverter = () => {
return {
plugins: ['eslint-plugin-react'],
plugins: ["eslint-plugin-react"],
rules: [
{
ruleName: "react/no-danger",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export const convertReactTsxCurlySpacing: RuleConverter = (tslintRule) => {
ruleArguments: [
{
...(tslintRule.ruleArguments.length > 1 && tslintRule.ruleArguments[1]),
'when': tslintRule.ruleArguments[0],
}
when: tslintRule.ruleArguments[0],
},
],
ruleName: "react/jsx-curly-spacing",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ describe(convertNoCookies, () => {
ruleArguments: [
{
message: "Forbidden call to document.cookie",
selector: 'MemberExpression[object.name="document"][property.name="cookie"]',
}
selector:
'MemberExpression[object.name="document"][property.name="cookie"]',
},
],
ruleName: "restricted-syntax",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ describe(convertNoDocumentDomain, () => {
{
ruleArguments: [
{
message: 'Forbidden write to document.domain.',
selector: 'AssignmentExpression[left.type="MemberExpression"][left.object.name="document"][left.property.name="domain"]',
message: "Forbidden write to document.domain.",
selector:
'AssignmentExpression[left.type="MemberExpression"][left.object.name="document"][left.property.name="domain"]',
},
{
message: 'Forbidden write to document.domain.',
selector: 'AssignmentExpression[left.type="MemberExpression"][left.object.type="MemberExpression"][left.object.object.name="window"][left.object.property.name="document"][left.property.name="domain"]',
message: "Forbidden write to document.domain.",
selector:
'AssignmentExpression[left.type="MemberExpression"][left.object.type="MemberExpression"][left.object.object.name="window"][left.object.property.name="document"][left.property.name="domain"]',
},
],
ruleName: "no-restricted-syntax",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ describe(convertNoDocumentWrite, () => {
{
ruleArguments: [
{
message: 'Forbidden call to document.write.',
selector: 'CallExpression[callee.type="MemberExpression"][callee.object.name="document"][callee.property.name=/^(write|writeln)$/]',
message: "Forbidden call to document.write.",
selector:
'CallExpression[callee.type="MemberExpression"][callee.object.name="document"][callee.property.name=/^(write|writeln)$/]',
},
{
message: 'Forbidden write to document.write.',
selector: 'CallExpression[callee.type="MemberExpression"][callee.object.type="MemberExpression"][callee.object.object.name="window"][callee.object.property.name="document"][callee.property.name=/^(write|writeln)$/]',
message: "Forbidden write to document.write.",
selector:
'CallExpression[callee.type="MemberExpression"][callee.object.type="MemberExpression"][callee.object.object.name="window"][callee.object.property.name="document"][callee.property.name=/^(write|writeln)$/]',
},
],
ruleName: "no-restricted-syntax",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe(convertNoExecScript, () => {
{
message: "Forbidden call to execScript",
selector: 'CallExpression[callee.name="execScript"]',
}
},
],
ruleName: "restricted-syntax",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ describe(convertReactA11yAccessibleHeadings, () => {

test("conversion with an argument", () => {
const result = convertReactA11yAccessibleHeadings({
ruleArguments: [{
maxHeadingLength: 23,
}],
ruleArguments: [
{
maxHeadingLength: 23,
},
],
});

expect(result).toEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ describe(convertReactA11yAnchors, () => {

test("conversion with arguments", () => {
const result = convertReactA11yAnchors({
ruleArguments: [{
'ignore-case': true,
'ignore-whitespace': 'trim'
}],
ruleArguments: [
{
"ignore-case": true,
"ignore-whitespace": "trim",
},
],
});

expect(result).toEqual({
notices: [
`jsx-a11y/anchor-is-valid does not support the 'ignore-case' option.`,
`jsx-a11y/anchor-is-valid does not support the 'ignore-whitespace' option.`
`jsx-a11y/anchor-is-valid does not support the 'ignore-whitespace' option.`,
],
plugins: ["jsx-a11y"],
rules: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe(convertReactNoDangerousHtml, () => {
});

expect(result).toEqual({
plugins: ['eslint-plugin-react'],
plugins: ["eslint-plugin-react"],
rules: [
{
ruleName: "react/no-danger",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ import { convertReactTsxCurlySpacing } from "../react-tsx-curly-spacing";
describe(convertReactTsxCurlySpacing, () => {
test("conversion with 'always'", () => {
const result = convertReactTsxCurlySpacing({
ruleArguments: ['always'],
ruleArguments: ["always"],
});

expect(result).toEqual({
plugins: ["eslint-plugin-react"],
rules: [
{
ruleArguments: [
{ when: 'always' }
],
ruleArguments: [{ when: "always" }],
ruleName: "react/jsx-curly-spacing",
},
],
Expand All @@ -21,16 +19,14 @@ describe(convertReactTsxCurlySpacing, () => {

test("conversion with 'never'", () => {
const result = convertReactTsxCurlySpacing({
ruleArguments: ['never'],
ruleArguments: ["never"],
});

expect(result).toEqual({
plugins: ["eslint-plugin-react"],
rules: [
{
ruleArguments: [
{ when: 'never' }
],
ruleArguments: [{ when: "never" }],
ruleName: "react/jsx-curly-spacing",
},
],
Expand All @@ -39,17 +35,19 @@ describe(convertReactTsxCurlySpacing, () => {

test("conversion with 'never' and 'allowMultiline'", () => {
const result = convertReactTsxCurlySpacing({
ruleArguments: ['never', { allowMultiline: true }],
ruleArguments: ["never", { allowMultiline: true }],
});

expect(result).toEqual({
plugins: ["eslint-plugin-react"],
rules: [
{
ruleArguments: [{
allowMultiline: true,
when: 'never',
}],
ruleArguments: [
{
allowMultiline: true,
when: "never",
},
],
ruleName: "react/jsx-curly-spacing",
},
],
Expand Down
7 changes: 4 additions & 3 deletions src/input/findOriginalConfigurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ export const findOriginalConfigurations = async (
};

const getMissingPackageMessage = (error: Error) => {
const match = /(Cannot find module|could not require|couldn't find the plugin) ([a-zA-Z0-9-_"'@/]+)/.exec(
error.message.split("\n").slice(0, 2).join("\n"),
);
const match =
/(Cannot find module|could not require|couldn't find the plugin) ([a-zA-Z0-9-_"'@/]+)/.exec(
error.message.split("\n").slice(0, 2).join("\n"),
);
if (match === null) {
return undefined;
}
Expand Down