-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 arguments object #3102
Conversation
1 similar comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest parameters are available by default in Node 6 and above so there should be no issue with the versions supported by Hexo.
I added some other comments but overall it's a good change. Thanks.
I'd still would prefer others to check this PR.
const end = arguments[5]; | ||
const args = arguments[3].split('=').shift(); | ||
let content = arguments[4]; | ||
data.content = data.content.replace(rBacktick, ($0, start, $2, _args, content, end) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to use non-capturing groups (?:
)
in the regular expressions to avoid unused arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\2 is used in the RegExp literal and can not be deleted with node v6.
const rBacktick = /(\s*)(`{3,}|~{3,}) *(.*) *\n([\s\S]+?)\s*\2(\n+|$)/g;
lib/plugins/renderer/swig.js
Outdated
swig.setTag('for', forTag.parse, function(compiler, args, content, parents, options, blockName) { | ||
const compile = forTag.compile.apply(this, arguments).split('\n'); | ||
swig.setTag('for', forTag.parse, function(...args) { | ||
const compile = forTag.compile.apply(this, args).split('\n'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the thisArg used in forTag.compile
? If no, it could be simplified to forTag.compile(...args).split('\n')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know if the value of this
in the callback of swig.setTag()
and the value of this
in forTag.compile()
do not know whether it works correctly or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/node-swig/swig-templates/blob/master/lib/tags/for.js
swig-tamplate@v2.0.2 does not use thisArg.
So, I tracked the relevant Node versions and I confirm it's fine. Rest parameters are supported since Node 6. |
* refactor: split function * lodash.toArray to rest param * remove arguments * no use arguments * fix param * forTag.compile() does not use thisArg.
Thank you for creating a pull request to contribute to Hexo code! Before you open the request please review the following guidelines and tips to help it be more easily integrated: