github.com/JohnnyEstilles
twitter.com/JohnnyEstilles
linkedin.com/in/johnnyestilles
johnny@freelancer.com
import * as _ from 'underscore';
_.mapObject({start: 5, end: 12}, function(val, key) {
return val + 5;
});
Sort of ... The ES Tree Spec
$ npm install --save-dev eslintmodule.exports = {
meta: {
messages: {
shortName: "Function parameter name too short: '{{ name }}'"
}
},
create(context) {
return {
FunctionDeclaration(node) {
node.params.forEach(identifier => {
if (identifier.name.length < 3) {å
context.report({
node: identifier,
messageId: 'shortName',
data: {
name: 'foo'
}
});
}
});
}
};
}
};
rules/no-short-params.js
{
"parserOptions": {
"ecmaVersion": 6
},
"rules": {
"no-short-params": 1
}
}
.eslintrc
node_modules/.bin/eslint --rulesdir=./rules test.js
/Users/johnnyestilles/Training/eslint-cumstom-rules/test.js
1:14 warning Function parameter name too short: 'foo' no-short-params
1:17 warning Function parameter name too short: 'foo' no-short-params
✖ 2 problems (0 errors, 2 warnings)Text
Install the VS Code ESLint extension
{
"eslint.options": {
"rulePaths": ["./rules"]
}
}.vscode/settings.json