Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jun 13, 2020
1 parent 42e9445 commit 5c9a336
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 43 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"dependencies": {
"deep-strict-equal": "^0.2.0",
"enhance-visitors": "^1.0.0",
"espree": "^6.1.2",
"espree": "^7.1.0",
"espurify": "^2.0.1",
"import-modules": "^2.0.0",
"micro-spelling-correcter": "^1.1.1",
Expand All @@ -42,19 +42,19 @@
"devDependencies": {
"ava": "^2.3.0",
"babel-eslint": "^10.0.2",
"chalk": "^2.4.2",
"chalk": "^4.1.0",
"del": "^5.0.0",
"eslint": "6.2.0",
"eslint-ava-rule-tester": "^3.0.0",
"eslint-plugin-eslint-plugin": "2.1.0",
"execa": "^2.0.4",
"eslint-ava-rule-tester": "^4.0.0",
"eslint-plugin-eslint-plugin": "^2.2.2",
"execa": "^4.0.2",
"js-combinatorics": "^0.5.4",
"listr": "^0.14.3",
"nyc": "^14.1.1",
"nyc": "^15.1.0",
"outdent": "^0.7.0",
"pify": "^4.0.1",
"tempy": "^0.3.0",
"xo": "^0.24.0"
"pify": "^5.0.0",
"tempy": "^0.5.0",
"xo": "^0.32.0"
},
"peerDependencies": {
"eslint": ">=6.2.0"
Expand Down
6 changes: 4 additions & 2 deletions rules/hooks-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ const create = context => {

const sourceCode = context.getSourceCode();

// TODO: Remove `.reduce()` usage.
// eslint-disable-next-line unicorn/no-reduce
const selectors = checks.reduce((result, check) => {
result[check.selector] = visitIf([
ava.isInTestFile,
Expand Down Expand Up @@ -117,11 +119,11 @@ const create = context => {
const start = nodeEarlier.parent.range[1];
const end = node.parent.range[1];

let text = sourceCode.getText().substring(start, end);
let text = sourceCode.getText().slice(start, end);

// Preserve newline previously between hooks
if (source.length >= (start + 1) && source[start + 1] === '\n') {
text = text.substring(1) + '\n';
text = text.slice(1) + '\n';
}

// Preserve newline that was previously before hooks
Expand Down
4 changes: 2 additions & 2 deletions rules/max-asserts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const createAvaRule = require('../create-ava-rule');

const MAX_ASSERTIONS_DEFAULT = 5;

const notAssertionMethods = ['plan', 'end'];
const notAssertionMethods = new Set(['plan', 'end']);

const create = context => {
const ava = createAvaRule();
Expand All @@ -28,7 +28,7 @@ const create = context => {

if (
callee.property &&
!notAssertionMethods.includes(callee.property.name) &&
!notAssertionMethods.has(callee.property.name) &&
util.getNameOfRootNodeObject(callee) === 't'
) {
const members = util.getMembers(callee).filter(name => name !== 'skip');
Expand Down
6 changes: 4 additions & 2 deletions rules/no-duplicate-modifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ const create = context => {
return;
}

testModifiers.reduce((prev, current) => {
if (prev.name === current.name) {
// TODO: Remove `.reduce()` usage.
// eslint-disable-next-line unicorn/no-reduce
testModifiers.reduce((previous, current) => {
if (previous.name === current.name) {
context.report({
node: current,
message: `Duplicate test modifier \`.${current.name}\`.`
Expand Down
2 changes: 1 addition & 1 deletion rules/no-identical-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const createAvaRule = require('../create-ava-rule');

const purify = node => node && espurify(node);

const isStaticTemplateLiteral = node => node.expressions.every(isStatic);
const isStaticTemplateLiteral = node => node.expressions.every(expression => isStatic(expression));

const isStatic = node => node.type === 'Literal' ||
(node.type === 'TemplateLiteral' && isStaticTemplateLiteral(node)) ||
Expand Down
2 changes: 1 addition & 1 deletion rules/no-statement-after-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const create = context => {

currentSegmentInfo = {
ended: false,
prev: segment.prevSegments.map(prevSegment => segmentInfoMap.get(prevSegment.id))
prev: segment.prevSegments.map(previousSegment => segmentInfoMap.get(previousSegment.id))
};

segmentInfoMap.set(segment.id, currentSegmentInfo);
Expand Down
2 changes: 1 addition & 1 deletion rules/no-todo-implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const create = context => {
ava.isInTestFile,
ava.isTestNode
])(node => {
if (ava.hasTestModifier('todo') && node.arguments.some(util.isFunctionExpression)) {
if (ava.hasTestModifier('todo') && node.arguments.some(argument => util.isFunctionExpression(argument))) {
context.report({
node,
message: '`test.todo()` should not be passed an implementation function.'
Expand Down
6 changes: 3 additions & 3 deletions rules/no-unknown-modifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {visitIf} = require('enhance-visitors');
const util = require('../util');
const createAvaRule = require('../create-ava-rule');

const modifiers = [
const modifiers = new Set([
'after',
'afterEach',
'always',
Expand All @@ -15,10 +15,10 @@ const modifiers = [
'skip',
'todo',
'failing'
];
]);

const unknownModifiers = node => util.getTestModifiers(node)
.filter(modifier => !modifiers.includes(modifier.name));
.filter(modifier => !modifiers.has(modifier.name));

const create = context => {
const ava = createAvaRule();
Expand Down
6 changes: 3 additions & 3 deletions rules/prefer-t-regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ const util = require('../util');
const create = context => {
const ava = createAvaRule();

const booleanTests = [
const booleanTests = new Set([
'true',
'false',
'truthy',
'falsy'
];
]);

const findReference = name => {
const reference = context.getScope().references.find(reference => reference.identifier.name === name);
Expand All @@ -26,7 +26,7 @@ const create = context => {
])(node => {
// Call a boolean assertion, for example, `t.true`, `t.false`, …
const isBooleanAssertion = node.callee.type === 'MemberExpression' &&
booleanTests.includes(node.callee.property.name) &&
booleanTests.has(node.callee.property.name) &&
util.getNameOfRootNodeObject(node.callee) === 't';

if (!isBooleanAssertion) {
Expand Down
6 changes: 3 additions & 3 deletions rules/use-true-false.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const deepStrictEqual = require('deep-strict-equal');
const util = require('../util');
const createAvaRule = require('../create-ava-rule');

const booleanBinaryOperators = [
const booleanBinaryOperators = new Set([
'==',
'===',
'!=',
Expand All @@ -15,7 +15,7 @@ const booleanBinaryOperators = [
'<=',
'>',
'>='
];
]);

const knownBooleanSignatures = [
'isFinite()',
Expand Down Expand Up @@ -62,7 +62,7 @@ const create = context => {
const argument = node.arguments[0];

if (argument &&
((argument.type === 'BinaryExpression' && booleanBinaryOperators.includes(argument.operator)) ||
((argument.type === 'BinaryExpression' && booleanBinaryOperators.has(argument.operator)) ||
(argument.type === 'UnaryExpression' && argument.operator === '!') ||
(argument.type === 'Literal' && argument.value === Boolean(argument.value)) ||
(matchesKnownBooleanExpression(argument)))
Expand Down
6 changes: 3 additions & 3 deletions test/no-statement-after-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ const errors = [{ruleId: 'no-statement-after-end'}];
const header = 'const test = require(\'ava\');\n';

function cbTest(contents, prependHeader) {
let ret = `test.cb(t => { ${contents} });`;
let returnValue = `test.cb(t => { ${contents} });`;

if (prependHeader !== false) {
ret = header + ret;
returnValue = header + returnValue;
}

return ret;
return returnValue;
}

ruleTester.run('no-statement-after-end', rule, {
Expand Down
6 changes: 3 additions & 3 deletions test/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ test('Every rule is defined in readme.md usage and list of rules in alphabetical
const readme = await pify(fs.readFile)('readme.md', 'utf8');
let usageRules;
try {
const usageRulesMatch = /## Usage.*?"rules": (\{.*?\})/ms.exec(readme);
const usageRulesMatch = /## Usage.*?"rules": ({.*?})/ms.exec(readme);
t.truthy(usageRulesMatch, 'List of rules should be defined in readme.md ## Usage');
usageRules = JSON.parse(usageRulesMatch[1]);
} catch (_) {}
} catch {}

t.truthy(usageRules, 'List of rules should be defined in readme.md ## Usage and be valid JSON');

const rulesMatch = /## Rules(.*?)## Recommended config/ms.exec(readme);
t.truthy(rulesMatch, 'List of rules should be defined in readme.md in ## Rules before ## Recommended config');
const rulesText = rulesMatch[1];
const re = /- \[(.*?)\]\((.*?)\) - (.*)\n/gm;
const re = /- \[(.*?)]\((.*?)\) - (.*)\n/gm;
const rules = [];
let match;
do {
Expand Down
20 changes: 10 additions & 10 deletions util.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ exports.loadAvaHelper = (filename, overrides) => {
return avaHelper.load(rootDir, overrides);
};

const functionExpressions = [
const functionExpressions = new Set([
'FunctionExpression',
'ArrowFunctionExpression'
];
]);

exports.getRootNode = node => {
if (node.object.type === 'MemberExpression') {
Expand All @@ -40,7 +40,7 @@ exports.isPropertyUnderContext = node => {
return exports.getRootNode(node).property.name === 'context';
};

exports.isFunctionExpression = node => node && functionExpressions.includes(node.type);
exports.isFunctionExpression = node => node && functionExpressions.has(node.type);

function getTestModifiers(node) {
if (node.type === 'CallExpression') {
Expand All @@ -60,11 +60,11 @@ exports.getTestModifier = (node, mod) => {
return getTestModifiers(node).find(property => property.name === mod);
};

exports.removeTestModifier = params => {
const modifier = params.modifier.trim();
const range = exports.getTestModifier(params.node, modifier).range.slice();
exports.removeTestModifier = parameters => {
const modifier = parameters.modifier.trim();
const range = exports.getTestModifier(parameters.node, modifier).range.slice();
const replacementRegExp = new RegExp(`\\.|${modifier}`, 'g');
const source = params.context.getSourceCode().getText();
const source = parameters.context.getSourceCode().getText();
let dotPosition = range[0] - 1;
while (source.charAt(dotPosition) !== '.') {
dotPosition -= 1;
Expand Down Expand Up @@ -97,7 +97,7 @@ const getDocsUrl = (filename, commitHash) => {

exports.getDocsUrl = getDocsUrl;

const assertionMethodsNumArguments = new Map([
const assertionMethodsNumberArguments = new Map([
['assert', 1],
['deepEqual', 2],
['fail', 0],
Expand All @@ -120,8 +120,8 @@ const assertionMethodsNumArguments = new Map([
['try', 1]
]);

const assertionMethodNames = [...assertionMethodsNumArguments.keys()];
const assertionMethodNames = [...assertionMethodsNumberArguments.keys()];

exports.assertionMethodsNumArguments = assertionMethodsNumArguments;
exports.assertionMethodsNumArguments = assertionMethodsNumberArguments;
exports.assertionMethods = new Set(assertionMethodNames);
exports.executionMethods = new Set(assertionMethodNames.concat(['end', 'plan', 'log', 'teardown', 'timeout']));

0 comments on commit 5c9a336

Please sign in to comment.