Skip to content

Commit 48e3a59

Browse files
authored
chore: precompile with babel (#257)
1 parent 8670804 commit 48e3a59

File tree

74 files changed

+798
-51
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+798
-51
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
coverage/
2+
lib/

.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { globals } = require('./index').environments.globals;
3+
const { globals } = require('./').environments.globals;
44

55
module.exports = {
66
extends: [
@@ -32,6 +32,8 @@ module.exports = {
3232
},
3333
],
3434
'prettier/prettier': 'error',
35+
'node/no-unsupported-features/es-syntax': 'off',
36+
'node/no-unsupported-features/es-builtins': 'error',
3537
},
3638
overrides: [
3739
{

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
coverage/
3+
lib/

babel.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
module.exports = {
4+
presets: [['@babel/preset-env', { targets: { node: 6 } }]],
5+
};

package.json

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,31 @@
1616
},
1717
"files": [
1818
"docs/",
19-
"rules/",
20-
"processors/",
21-
"index.js"
19+
"src/",
20+
"lib/"
2221
],
22+
"main": "lib/",
2323
"engines": {
2424
"node": ">=6"
2525
},
2626
"peerDependencies": {
2727
"eslint": ">=5"
2828
},
2929
"scripts": {
30+
"postinstall": "yarn build",
3031
"lint": "eslint . --ignore-pattern '!.eslintrc.js'",
3132
"prettylint": "prettylint docs/**/*.md README.md package.json",
32-
"test": "jest"
33+
"prepublishOnly": "yarn build",
34+
"test": "jest",
35+
"build": "babel src --out-dir lib"
3336
},
3437
"devDependencies": {
38+
"@babel/cli": "^7.4.4",
39+
"@babel/core": "^7.4.4",
40+
"@babel/preset-env": "^7.4.4",
3541
"@commitlint/cli": "^7.0.0",
3642
"@commitlint/config-conventional": "^7.0.1",
43+
"babel-jest": "^24.8.0",
3744
"eslint": "^5.1.0",
3845
"eslint-config-prettier": "^4.1.0",
3946
"eslint-plugin-eslint-plugin": "^2.0.0",
@@ -49,7 +56,7 @@
4956
"prettier": {
5057
"proseWrap": "always",
5158
"singleQuote": true,
52-
"trailingComma": "es5"
59+
"trailingComma": "all"
5360
},
5461
"lint-staged": {
5562
"*.js": [
@@ -73,13 +80,19 @@
7380
"projects": [
7481
{
7582
"displayName": "test",
76-
"testEnvironment": "node"
83+
"testEnvironment": "node",
84+
"testPathIgnorePatterns": [
85+
"<rootDir>/lib/.*"
86+
]
7787
},
7888
{
7989
"displayName": "lint",
8090
"runner": "jest-runner-eslint",
8191
"testMatch": [
8292
"<rootDir>/**/*.js"
93+
],
94+
"testPathIgnorePatterns": [
95+
"<rootDir>/lib/.*"
8396
]
8497
}
8598
]

__tests__/rules.test.js renamed to src/__tests__/rules.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
const fs = require('fs');
44
const path = require('path');
5-
const { rules } = require('../index');
5+
const { rules } = require('../');
66

77
const ruleNames = Object.keys(rules);
88
const numberOfRules = 31;
99

1010
describe('rules', () => {
1111
it('should have a corresponding doc for each rule', () => {
1212
ruleNames.forEach(rule => {
13-
const docPath = path.resolve(__dirname, '../docs/rules', `${rule}.md`);
13+
const docPath = path.resolve(__dirname, '../../docs/rules', `${rule}.md`);
1414

1515
if (!fs.existsSync(docPath)) {
1616
throw new Error(
17-
`Could not find documentation file for rule "${rule}" in path "${docPath}"`
17+
`Could not find documentation file for rule "${rule}" in path "${docPath}"`,
1818
);
1919
}
2020
});
@@ -24,7 +24,7 @@ describe('rules', () => {
2424
const { length } = ruleNames;
2525
if (length !== numberOfRules) {
2626
throw new Error(
27-
`There should be exactly ${numberOfRules} rules, but there are ${length}. If you've added a new rule, please update this number.`
27+
`There should be exactly ${numberOfRules} rules, but there are ${length}. If you've added a new rule, please update this number.`,
2828
);
2929
}
3030
});

index.js renamed to src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const rules = fs
99
.map(rule => path.basename(rule, '.js'))
1010
.reduce(
1111
(acc, curr) => Object.assign(acc, { [curr]: require(`./rules/${curr}`) }),
12-
{}
12+
{},
1313
);
1414

1515
const snapshotProcessor = require('./processors/snapshot-processor');

processors/snapshot-processor.js renamed to src/processors/snapshot-processor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const preprocess = source => [source];
66
const postprocess = messages =>
77
messages[0].filter(
88
// snapshot files should only be linted with snapshot specific rules
9-
message => message.ruleId === 'jest/no-large-snapshots'
9+
message => message.ruleId === 'jest/no-large-snapshots',
1010
);
1111

1212
module.exports = {

rules/__tests__/consistent-test-it.test.js renamed to src/rules/__tests__/consistent-test-it.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ ruleTester.run(
285285
output: 'test("foo")',
286286
},
287287
],
288-
}
288+
},
289289
);
290290

291291
ruleTester.run('consistent-test-it with fn=it and withinDescribe=it ', rule, {

rules/__tests__/no-identical-title.test.js renamed to src/rules/__tests__/no-identical-title.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ ruleTester.run('no-identical-title', rule, {
2323
['it("it1", function() {});', 'it("it2", function() {});'].join('\n'),
2424
['it.only("it1", function() {});', 'it("it2", function() {});'].join('\n'),
2525
['it.only("it1", function() {});', 'it.only("it2", function() {});'].join(
26-
'\n'
26+
'\n',
2727
),
2828
['describe("title", function() {});', 'it("title", function() {});'].join(
29-
'\n'
29+
'\n',
3030
),
3131
[
3232
'describe("describe1", function() {',
@@ -136,7 +136,7 @@ ruleTester.run('no-identical-title', rule, {
136136
},
137137
{
138138
code: ['it("it1", function() {});', 'it("it1", function() {});'].join(
139-
'\n'
139+
'\n',
140140
),
141141
errors: [
142142
{
@@ -163,7 +163,7 @@ ruleTester.run('no-identical-title', rule, {
163163
},
164164
{
165165
code: ['fit("it1", function() {});', 'it("it1", function() {});'].join(
166-
'\n'
166+
'\n',
167167
),
168168
errors: [
169169
{

rules/__tests__/no-large-snapshots.test.js renamed to src/rules/__tests__/no-large-snapshots.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ ruleTester.run('no-large-snapshots', rule, {
1515
{
1616
filename: 'mock.js',
1717
code: `expect(something).toMatchInlineSnapshot(\`\n${'line\n'.repeat(
18-
2
18+
2,
1919
)}\`);`,
2020
},
2121
{
2222
filename: 'mock.js',
2323
code: `expect(something).toThrowErrorMatchingInlineSnapshot(\`\n${'line\n'.repeat(
24-
2
24+
2,
2525
)}\`);`,
2626
},
2727
],
2828
invalid: [
2929
{
3030
filename: 'mock.js',
3131
code: `expect(something).toMatchInlineSnapshot(\`\n${'line\n'.repeat(
32-
50
32+
50,
3333
)}\`);`,
3434
errors: [
3535
{
@@ -41,7 +41,7 @@ ruleTester.run('no-large-snapshots', rule, {
4141
{
4242
filename: 'mock.js',
4343
code: `expect(something).toThrowErrorMatchingInlineSnapshot(\`\n${'line\n'.repeat(
44-
50
44+
50,
4545
)}\`);`,
4646
errors: [
4747
{

rules/consistent-test-it.js renamed to src/rules/consistent-test-it.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ module.exports = {
6969
nodeName.indexOf(testKeywordWithinDescribe) === -1
7070
) {
7171
const oppositeTestKeyword = getOppositeTestKeyword(
72-
testKeywordWithinDescribe
72+
testKeywordWithinDescribe,
7373
);
7474

7575
context.report({
@@ -85,7 +85,7 @@ module.exports = {
8585

8686
const fixedNodeName = getPreferredNodeName(
8787
nodeName,
88-
testKeywordWithinDescribe
88+
testKeywordWithinDescribe,
8989
);
9090
return [fixer.replaceText(nodeToReplace, fixedNodeName)];
9191
},

rules/expect-expect.js renamed to src/rules/expect-expect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = {
3030
const assertFunctionNames = new Set(
3131
context.options[0] && context.options[0].assertFunctionNames
3232
? context.options[0].assertFunctionNames
33-
: ['expect']
33+
: ['expect'],
3434
);
3535

3636
return {
@@ -54,7 +54,7 @@ module.exports = {
5454
context.report({
5555
message: 'Test has no assertions',
5656
node,
57-
})
57+
}),
5858
);
5959
},
6060
};
File renamed without changes.

rules/no-alias-methods.js renamed to src/rules/no-alias-methods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = {
4747

4848
// Check if the method used matches any of ours
4949
const methodItem = methodNames.find(
50-
item => item[1] === targetNode.name
50+
item => item[1] === targetNode.name,
5151
);
5252

5353
if (methodItem) {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

rules/no-identical-title.js renamed to src/rules/no-identical-title.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = {
7575
context,
7676
currentLayer.describeTitles,
7777
node,
78-
title
78+
title,
7979
);
8080
},
8181
'CallExpression:exit'(node) {

rules/no-jasmine-globals.js renamed to src/rules/no-jasmine-globals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ module.exports = {
127127
return [
128128
fixer.replaceText(
129129
node.parent,
130-
`jest.setTimeout(${node.parent.right.value})`
130+
`jest.setTimeout(${node.parent.right.value})`,
131131
),
132132
];
133133
},
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

rules/prefer-inline-snapshots.js renamed to src/rules/prefer-inline-snapshots.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
return [
2020
fixer.replaceText(
2121
node.callee.property,
22-
'toMatchInlineSnapshot'
22+
'toMatchInlineSnapshot',
2323
),
2424
];
2525
},
@@ -32,7 +32,7 @@ module.exports = {
3232
return [
3333
fixer.replaceText(
3434
node.callee.property,
35-
'toThrowErrorMatchingInlineSnapshot'
35+
'toThrowErrorMatchingInlineSnapshot',
3636
),
3737
];
3838
},

rules/prefer-spy-on.js renamed to src/rules/prefer-spy-on.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ module.exports = {
5454
fixer.insertTextBefore(node.left, `jest.spyOn(`),
5555
fixer.replaceTextRange(
5656
[node.left.object.range[1], node.left.property.range[0]],
57-
`, ${leftPropQuote}`
57+
`, ${leftPropQuote}`,
5858
),
5959
fixer.replaceTextRange(
6060
[node.left.property.range[1], jestFnCall.range[1]],
61-
`${leftPropQuote})${mockImplementation}`
61+
`${leftPropQuote})${mockImplementation}`,
6262
),
6363
];
6464
},
File renamed without changes.
File renamed without changes.
File renamed without changes.

rules/prefer-to-contain.js renamed to src/rules/prefer-to-contain.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const getNegationFixes = (node, sourceCode, fixer) => {
3939
const negationPropertyDot = sourceCode.getFirstTokenBetween(
4040
node.parent.object,
4141
node.parent.property,
42-
token => token.value === '.'
42+
token => token.value === '.',
4343
);
4444
const toContainFunc =
4545
isEqualityNegation(node) && argument(node.parent).value
@@ -63,7 +63,7 @@ const getCommonFixes = (node, sourceCode, fixer) => {
6363
const propertyDot = sourceCode.getFirstTokenBetween(
6464
includesCaller.object,
6565
includesCaller.property,
66-
token => token.value === '.'
66+
token => token.value === '.',
6767
);
6868

6969
const closingParenthesis = sourceCode.getTokenAfter(containArg);
@@ -114,8 +114,8 @@ module.exports = {
114114
fixArr.push(
115115
fixer.replaceText(
116116
argument(node),
117-
sourceCode.getText(containArg)
118-
)
117+
sourceCode.getText(containArg),
118+
),
119119
);
120120
return fixArr;
121121
},

rules/prefer-to-have-length.js renamed to src/rules/prefer-to-have-length.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = {
3535
.getFirstTokenBetween(
3636
node.arguments[0].object,
3737
node.arguments[0].property,
38-
token => token.value === '.'
38+
token => token.value === '.',
3939
);
4040
context.report({
4141
fix(fixer) {
File renamed without changes.

rules/util.js renamed to src/rules/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const path = require('path');
4-
const { version } = require('../package.json');
4+
const { version } = require('../../package.json');
55

66
const REPO_URL = 'https://github.com/jest-community/eslint-plugin-jest';
77

File renamed without changes.

rules/valid-expect-in-promise.js renamed to src/rules/valid-expect-in-promise.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const verifyExpectWithReturn = (
9898
promiseCallbacks,
9999
node,
100100
context,
101-
testFunctionBody
101+
testFunctionBody,
102102
) => {
103103
promiseCallbacks.some(promiseCallback => {
104104
if (promiseCallback && isFunction(promiseCallback)) {
@@ -156,7 +156,7 @@ module.exports = {
156156
[fulfillmentCallback, rejectionCallback],
157157
node,
158158
context,
159-
testFunctionBody
159+
testFunctionBody,
160160
);
161161
}
162162
}
File renamed without changes.

0 commit comments

Comments
 (0)