Skip to content

Commit

Permalink
Upgrade XO
Browse files Browse the repository at this point in the history
  • Loading branch information
novemberborn committed Sep 18, 2021
1 parent 7ce7a43 commit 39a86dc
Show file tree
Hide file tree
Showing 62 changed files with 942 additions and 962 deletions.
109 changes: 54 additions & 55 deletions create-ava-rule.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
'use strict';
const {isDeepStrictEqual} = require('util');
const espurify = require('espurify');
const enhance = require('enhance-visitors');
Expand All @@ -11,92 +10,92 @@ const avaImportDeclarationAsts = [{
type: 'ImportDefaultSpecifier',
local: {
type: 'Identifier',
name: 'test'
}
}
name: 'test',
},
},
],
source: {
type: 'Literal',
value: 'ava'
}
value: 'ava',
},
}, {
type: 'ImportDeclaration',
specifiers: [
{
type: 'ImportSpecifier',
imported: {
type: 'Identifier',
name: 'serial'
name: 'serial',
},
local: {
type: 'Identifier',
name: 'test'
}
}
name: 'test',
},
},
],
source: {
type: 'Literal',
value: 'ava'
}
value: 'ava',
},
}, {
type: 'ImportDeclaration',
specifiers: [
{
type: 'ImportSpecifier',
imported: {
type: 'Identifier',
name: 'serial'
name: 'serial',
},
local: {
type: 'Identifier',
name: 'test'
}
}
name: 'test',
},
},
],
source: {
type: 'Literal',
value: 'ava'
}
value: 'ava',
},
}, {
type: 'ImportDeclaration',
specifiers: [
{
type: 'ImportSpecifier',
imported: {
type: 'Identifier',
name: 'serial'
name: 'serial',
},
local: {
type: 'Identifier',
name: 'serial'
}
}
name: 'serial',
},
},
],
source: {
type: 'Literal',
value: 'ava'
}
value: 'ava',
},
}];

const avaVariableDeclaratorAsts = [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: 'test'
name: 'test',
},
init: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'require'
name: 'require',
},
arguments: [
{
type: 'Literal',
value: 'ava'
}
]
}
value: 'ava',
},
],
},
}, {
type: 'VariableDeclarator',
id: {
Expand All @@ -105,31 +104,31 @@ const avaVariableDeclaratorAsts = [{
type: 'Property',
key: {
type: 'Identifier',
name: 'serial'
name: 'serial',
},
value: {
type: 'Identifier',
name: 'serial'
name: 'serial',
},
kind: 'init',
method: false,
shorthand: true,
computed: false
}]
computed: false,
}],
},
init: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'require'
name: 'require',
},
arguments: [
{
type: 'Literal',
value: 'ava'
}
]
}
value: 'ava',
},
],
},
}, {
type: 'VariableDeclarator',
id: {
Expand All @@ -138,31 +137,31 @@ const avaVariableDeclaratorAsts = [{
type: 'Property',
key: {
type: 'Identifier',
name: 'serial'
name: 'serial',
},
value: {
type: 'Identifier',
name: 'test'
name: 'test',
},
kind: 'init',
method: false,
shorthand: false,
computed: false
}]
computed: false,
}],
},
init: {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'require'
name: 'require',
},
arguments: [
{
type: 'Literal',
value: 'ava'
}
]
}
value: 'ava',
},
],
},
}];

function isTestFunctionCall(node) {
Expand Down Expand Up @@ -211,22 +210,22 @@ module.exports = () => { // eslint-disable-line eslint-plugin/prefer-object-rule
},
'Program:exit': () => {
isTestFile = false;
}
},
};

return {
hasTestModifier: mod => getTestModifierNames(currentTestNode).includes(mod),
hasNoUtilityModifier: () => {
const modifiers = getTestModifierNames(currentTestNode);
return !modifiers.includes('before') &&
!modifiers.includes('beforeEach') &&
!modifiers.includes('after') &&
!modifiers.includes('afterEach') &&
!modifiers.includes('macro');
return !modifiers.includes('before')
&& !modifiers.includes('beforeEach')
&& !modifiers.includes('after')
&& !modifiers.includes('afterEach')
&& !modifiers.includes('macro');
},
isInTestFile: () => isTestFile,
isInTestNode: () => currentTestNode,
isTestNode: node => currentTestNode === node,
merge: customHandlers => enhance.mergeVisitors([predefinedRules, customHandlers])
merge: customHandlers => enhance.mergeVisitors([predefinedRules, customHandlers]),
};
};
17 changes: 8 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
'use strict';
const path = require('path');
const importModules = require('import-modules');

Expand All @@ -7,21 +6,21 @@ module.exports = {
configs: {
recommended: {
env: {
es6: true
es6: true,
},
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module'
sourceType: 'module',
},
plugins: [
'ava'
'ava',
],
rules: {
'ava/assertion-arguments': 'error',
'ava/hooks-order': 'error',
'ava/max-asserts': [
'off',
5
5,
],
'ava/no-async-fn-without-await': 'error',
'ava/no-duplicate-modifiers': 'error',
Expand All @@ -46,8 +45,8 @@ module.exports = {
'ava/use-t': 'error',
'ava/use-t-throws-async-well': 'error',
'ava/use-test': 'error',
'ava/use-true-false': 'error'
}
}
}
'ava/use-true-false': 'error',
},
},
},
};
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"outdent": "^0.8.0",
"pify": "^5.0.0",
"tempy": "^1.0.1",
"xo": "^0.38.2"
"xo": "^0.44.0"
},
"peerDependencies": {
"eslint": ">=7.22.0"
Expand Down Expand Up @@ -80,7 +80,10 @@
],
"rules": {
"ava/no-ignored-test-files": "off",
"import/extensions": "off"
"eslint-plugin/prefer-message-ids": "off",
"eslint-plugin/require-meta-docs-description": "off",
"import/extensions": "off",
"unicorn/prefer-module": "off"
}
},
"c8": {
Expand Down
Loading

0 comments on commit 39a86dc

Please sign in to comment.