Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
vagusX committed Jan 3, 2020
1 parent e699122 commit 38ef479
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jest.mock('../v3-component-with-string-icon-props-to-v4', () => {

const tests = [
'avatar',
// 'button',
// 'result',
// 'forked-avatar',
// 'forked-button',
// 'forked-result',
'button',
'result',
'forked-avatar',
'forked-button',
'forked-result',
];

const defineTest = require('jscodeshift/dist/testUtils').defineTest;
Expand Down
9 changes: 9 additions & 0 deletions transforms/utils/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,17 @@ function cleanup() {
fs.unlinkSync(summaryFilePath);
}

function addIconRelatedMsg(file, location, source) {
return appendLine(
`${file.path} - ${location.line}:${location.column}`,
source,
'Contains an invalid icon, please check it at https://ant.design/components/icon',
);
}

module.exports = {
start,
appendLine,
output,
addIconRelatedMsg,
};
10 changes: 3 additions & 7 deletions transforms/v3-component-with-string-icon-props-to-v4.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
addSubmoduleImport,
} = require('./utils');
const { printOptions } = require('./utils/config');
const { addIconRelatedMsg } = require('./utils/summary');
const {
createIconJSXElement,
getV4IconComponentName,
Expand Down Expand Up @@ -78,13 +79,8 @@ module.exports = (file, api, options) => {
return;
} else {
const location = path.node.loc.start;
const message =
'Contains an invalid icon, please check it at https://ant.design/components/icon';
summary.appendLine(
`${file.path} - ${location.line}:${location.column}`,
j(nodePath).toSource(),
message,
);

addIconRelatedMsg(file, location, j(nodePath).toSource());
}
}

Expand Down

0 comments on commit 38ef479

Please sign in to comment.