Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
chore: update prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
dferber90 committed Mar 22, 2020
1 parent 087de1b commit 59209ae
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 46 deletions.
12 changes: 6 additions & 6 deletions lib/rules/audit-argument-checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
meta: {
schema: [],
},
create: context => {
create: (context) => {
// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------
Expand All @@ -31,7 +31,7 @@ module.exports = {
}

if (node.body.type === 'BlockStatement') {
node.body.body.forEach(expression => {
node.body.body.forEach((expression) => {
if (
expression.type === 'ExpressionStatement' &&
expression.expression.type === 'CallExpression' &&
Expand All @@ -50,15 +50,15 @@ module.exports = {
expression.expression.arguments.length > 1 &&
expression.expression.arguments[0].type === 'ArrayExpression'
) {
expression.expression.arguments[0].elements.forEach(element => {
expression.expression.arguments[0].elements.forEach((element) => {
if (element.type === 'Identifier')
checkedParams.push(element.name);
});
}
});
}

node.params.forEach(param => {
node.params.forEach((param) => {
if (param.type === 'Identifier') {
if (checkedParams.indexOf(param.name) === -1) {
context.report(param, `"${param.name}" is not checked`);
Expand All @@ -72,7 +72,7 @@ module.exports = {
// ---------------------------------------------------------------------------

return {
CallExpression: node => {
CallExpression: (node) => {
// publications
if (isMeteorCall(node, 'publish') && node.arguments.length >= 2) {
auditArgumentChecks(node.arguments[1]);
Expand All @@ -85,7 +85,7 @@ module.exports = {
node.arguments.length > 0 &&
node.arguments[0].type === 'ObjectExpression'
) {
node.arguments[0].properties.forEach(property => {
node.arguments[0].properties.forEach((property) => {
auditArgumentChecks(property.value);
});
}
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/eventmap-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = {
},
],
},
create: context => {
create: (context) => {
// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -83,7 +83,7 @@ module.exports = {
// ---------------------------------------------------------------------------

return {
CallExpression: node => {
CallExpression: (node) => {
if (
node.arguments.length === 0 ||
!isTemplateProp(node.callee, 'events')
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/no-dom-lookup-on-created.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const errorMessage =
'Accessing DOM from "onCreated" is forbidden. Try from "onRendered" instead.';
const jQueryNames = new Set(['$', 'jQuery']);

const isJQueryCallee = node =>
const isJQueryCallee = (node) =>
// $()
(node.type === 'Identifier' && jQueryNames.has(node.name)) || // Template.instance().$()
(node.type === 'MemberExpression' &&
Expand All @@ -23,23 +23,23 @@ const isJQueryCallee = node =>
node.object.callee.object.name === 'Template' &&
getPropertyName(node.object.callee.property) === 'instance');

const isRelevantTemplateCallExpression = node =>
const isRelevantTemplateCallExpression = (node) =>
node.type === 'CallExpression' &&
node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'MemberExpression' &&
node.callee.object.object.type === 'Identifier' &&
node.callee.object.object.name === 'Template' &&
getPropertyName(node.callee.property) === 'onCreated';

const isInRelevantTemplateScope = ancestors =>
const isInRelevantTemplateScope = (ancestors) =>
ancestors.some(isRelevantTemplateCallExpression);

module.exports = {
meta: {
schema: [],
},
create: context => ({
CallExpression: node => {
create: (context) => ({
CallExpression: (node) => {
if (!isJQueryCallee(node.callee)) return;
if (!isInRelevantTemplateScope(context.getAncestors())) return;

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module.exports = {
meta: {
schema: [],
},
create: context => ({
MemberExpression: node => {
create: (context) => ({
MemberExpression: (node) => {
if (node.object.name === 'Session') {
context.report(node, 'Unexpected Session statement');
}
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-template-lifecycle-assignments.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
meta: {
schema: [],
},
create: context => {
create: (context) => {
// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -43,7 +43,7 @@ module.exports = {
// Public
// ---------------------------------------------------------------------------
return {
AssignmentExpression: node => {
AssignmentExpression: (node) => {
if (node.operator === '=') {
const lhs = node.left;
if (
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-template-parent-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module.exports = {
meta: {
schema: [],
},
create: context => ({
CallExpression: node => {
create: (context) => ({
CallExpression: (node) => {
if (
node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-zero-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module.exports = {
meta: {
schema: [],
},
create: context => ({
CallExpression: node => {
create: (context) => ({
CallExpression: (node) => {
if (isMeteorCall(node, 'setTimeout')) {
if (node.arguments.length === 1) {
context.report(node, 'Implicit timeout of 0');
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/prefer-session-equals.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* See LICENSE file in root directory for full license.
*/

const isSessionGetCallExpression = node =>
const isSessionGetCallExpression = (node) =>
node.type === 'CallExpression' &&
node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
Expand All @@ -25,13 +25,13 @@ module.exports = {
meta: {
schema: [],
},
create: context => {
create: (context) => {
// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------
const errorMessage = 'Use "Session.equals" instead';

const checkTest = node => {
const checkTest = (node) => {
switch (node.type) {
case 'BinaryExpression':
case 'LogicalExpression':
Expand All @@ -52,10 +52,10 @@ module.exports = {
// Public
// ---------------------------------------------------------------------------
return {
ConditionalExpression: node => {
ConditionalExpression: (node) => {
checkTest(node.test);
},
IfStatement: node => checkTest(node.test),
IfStatement: (node) => checkTest(node.test),
};
},
};
6 changes: 3 additions & 3 deletions lib/rules/prefix-eventmap-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
meta: {
schema: [{ type: 'string' }, { enum: ['relaxed', 'strict'] }],
},
create: context => {
create: (context) => {
// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------
Expand All @@ -29,7 +29,7 @@ module.exports = {

const spec = node.key.value;
const clauses = spec.split(/,\s+/);
clauses.forEach(clause => {
clauses.forEach((clause) => {
const parts = clause.split(/\s+/);

if (parts.length === 1) {
Expand Down Expand Up @@ -61,7 +61,7 @@ module.exports = {
// ---------------------------------------------------------------------------

return {
CallExpression: node => {
CallExpression: (node) => {
if (
node.arguments.length === 0 ||
!isTemplateProp(node.callee, 'events')
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/scope-dom-lookups.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ const relevantTemplatePropertyNames = new Set([
'helpers',
]);

const isJQueryIdentifier = node =>
const isJQueryIdentifier = (node) =>
node.type === 'Identifier' && jQueryNames.has(node.name);

const isRelevantTemplateCallExpression = node =>
const isRelevantTemplateCallExpression = (node) =>
node.type === 'CallExpression' &&
node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'MemberExpression' &&
node.callee.object.object.type === 'Identifier' &&
node.callee.object.object.name === 'Template' &&
relevantTemplatePropertyNames.has(getPropertyName(node.callee.property));

const isInRelevantTemplateScope = ancestors =>
const isInRelevantTemplateScope = (ancestors) =>
ancestors.some(isRelevantTemplateCallExpression);

module.exports = {
meta: {
schema: [],
},
create: context => ({
CallExpression: node => {
create: (context) => ({
CallExpression: (node) => {
if (!isJQueryIdentifier(node.callee)) return;
if (!isInRelevantTemplateScope(context.getAncestors())) return;
context.report(node, 'Use scoped DOM lookup instead');
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/template-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const NAMING_CONVENTIONS = {
UPPER_SNAKE: 'upper-snake-case',
};

const isTemplateMemberExpression = node =>
const isTemplateMemberExpression = (node) =>
node.object.type === 'MemberExpression' &&
node.object.object.type === 'Identifier' &&
node.object.object.name === 'Template' &&
Expand All @@ -35,18 +35,18 @@ const isTemplateMemberExpression = node =>
templateProps.has(node.property.name);

// assuming node type is always either Identifier or Literal
const getNameOfProperty = node =>
const getNameOfProperty = (node) =>
node.type === 'Identifier' ? node.name : node.value;

const getErrorMessage = expected =>
const getErrorMessage = (expected) =>
`Invalid template name, expected name to be in ${expected}`;

module.exports = {
meta: {
schema: [{ enum: values(NAMING_CONVENTIONS) }],
},
create: context => ({
MemberExpression: node => {
create: (context) => ({
MemberExpression: (node) => {
if (!isTemplateMemberExpression(node)) return;

const [namingConvention] = context.options;
Expand Down
4 changes: 2 additions & 2 deletions lib/util/executors/sets.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const invariant = require('invariant');
module.exports.difference = (a, b) => {
invariant(!!a, 'difference: Set a is not defined');
invariant(!!b, 'difference: Set b is not defined');
return new Set([...a].filter(x => !b.has(x)));
return new Set([...a].filter((x) => !b.has(x)));
};

// Set -> Set -> Set
Expand All @@ -18,5 +18,5 @@ module.exports.union = (a, b) => {
module.exports.intersection = (a, b) => {
invariant(!!a, 'intersection: Set a is not defined');
invariant(!!b, 'intersection: Set b is not defined');
return new Set([...a].filter(element => b.has(element)));
return new Set([...a].filter((element) => b.has(element)));
};
2 changes: 1 addition & 1 deletion lib/util/values.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = obj => Object.keys(obj).map(key => obj[key]);
module.exports = (obj) => Object.keys(obj).map((key) => obj[key]);
8 changes: 4 additions & 4 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ const { rules, configs } = require('../lib/index');

const ruleNames = fs
.readdirSync(path.resolve(__dirname, '../lib/rules/'))
.filter(f => path.extname(f) === '.js')
.map(f => path.basename(f, '.js'));
.filter((f) => path.extname(f) === '.js')
.map((f) => path.basename(f, '.js'));

describe('all rule files should be exported by the plugin', () => {
ruleNames.forEach(ruleName => {
ruleNames.forEach((ruleName) => {
it(`should export ${ruleName}`, () => {
assert({}.hasOwnProperty.call(rules, ruleName));
});
});
});

describe('configurations', () => {
ruleNames.forEach(ruleName => {
ruleNames.forEach((ruleName) => {
it(`should have a recommended configuration for ${ruleName}`, () => {
assert(
{}.hasOwnProperty.call(configs.recommended.rules, `meteor/${ruleName}`)
Expand Down

0 comments on commit 59209ae

Please sign in to comment.