Skip to content

Commit 1ce1402

Browse files
committed
fix: revert TypeScript migration
Fixes #268 Fixes #269 Fixes #270
1 parent 331457d commit 1ce1402

14 files changed

+162
-441
lines changed

.eslintrc.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
const { globals } = require('./').environments.globals;
44

55
module.exports = {
6-
parser: '@typescript-eslint/parser',
76
extends: [
7+
'eslint:recommended',
88
'plugin:eslint-plugin/recommended',
99
'plugin:node/recommended',
10-
'plugin:@typescript-eslint/eslint-recommended',
1110
'prettier',
1211
],
13-
plugins: ['eslint-plugin', 'node', 'prettier', '@typescript-eslint'],
12+
plugins: ['eslint-plugin', 'node', 'prettier'],
1413
parserOptions: {
1514
ecmaVersion: 2017,
1615
},
@@ -38,14 +37,8 @@ module.exports = {
3837
},
3938
overrides: [
4039
{
41-
files: ['*.test.js', '*.test.ts'],
40+
files: ['*.test.js'],
4241
globals,
4342
},
44-
{
45-
files: ['*.ts'],
46-
parserOptions: {
47-
sourceType: 'module',
48-
},
49-
},
5043
],
5144
};

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ script:
1414
- yarn commitlint --from="$TRAVIS_BRANCH" --to="$TRAVIS_COMMIT"
1515
- yarn commitlint --from=$TRAVIS_COMMIT
1616
- yarn prettylint
17-
- yarn typecheck
1817
- yarn test --coverage --maxWorkers 2
1918
after_script: greenkeeper-lockfile-upload
2019
jobs:

babel.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
'use strict';
22

33
module.exports = {
4-
presets: [
5-
'@babel/preset-typescript',
6-
['@babel/preset-env', { targets: { node: 6 } }],
7-
],
4+
presets: [['@babel/preset-env', { targets: { node: 6 } }]],
85
};

package.json

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,19 @@
2727
"eslint": ">=5"
2828
},
2929
"scripts": {
30-
"pretest": "yarn build",
31-
"lint": "eslint . --ignore-pattern '!.eslintrc.js' --ext js,ts",
30+
"prepare": "yarn build",
31+
"lint": "eslint . --ignore-pattern '!.eslintrc.js'",
3232
"prettylint": "prettylint docs/**/*.md README.md package.json",
3333
"prepublishOnly": "yarn build",
3434
"test": "jest",
35-
"build": "babel --extensions .js,.ts src --out-dir lib",
36-
"typecheck": "tsc -p ."
37-
},
38-
"dependencies": {
39-
"@typescript-eslint/experimental-utils": "^1.9.1-alpha.3"
35+
"build": "babel src --out-dir lib"
4036
},
4137
"devDependencies": {
4238
"@babel/cli": "^7.4.4",
4339
"@babel/core": "^7.4.4",
4440
"@babel/preset-env": "^7.4.4",
45-
"@babel/preset-typescript": "^7.3.3",
4641
"@commitlint/cli": "^7.0.0",
4742
"@commitlint/config-conventional": "^7.0.1",
48-
"@types/eslint": "^4.16.6",
49-
"@types/jest": "^24.0.12",
50-
"@types/node": "^12.0.0",
51-
"@typescript-eslint/eslint-plugin": "^1.9.1-alpha.3",
5243
"babel-jest": "^24.8.0",
5344
"eslint": "^5.1.0",
5445
"eslint-config-prettier": "^4.1.0",
@@ -60,16 +51,15 @@
6051
"jest-runner-eslint": "^0.7.1",
6152
"lint-staged": "^8.0.4",
6253
"prettier": "^1.10.2",
63-
"prettylint": "^1.0.0",
64-
"typescript": "^3.4.5"
54+
"prettylint": "^1.0.0"
6555
},
6656
"prettier": {
6757
"proseWrap": "always",
6858
"singleQuote": true,
6959
"trailingComma": "all"
7060
},
7161
"lint-staged": {
72-
"*.{js,ts}": [
62+
"*.js": [
7363
"eslint --fix",
7464
"git add"
7565
],

src/index.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,12 @@
33
const fs = require('fs');
44
const path = require('path');
55

6-
// copied from https://github.com/babel/babel/blob/56044c7851d583d498f919e9546caddf8f80a72f/packages/babel-helpers/src/helpers.js#L558-L562
7-
function interopRequireDefault(obj) {
8-
return obj && obj.__esModule ? obj : { default: obj };
9-
}
10-
116
const rules = fs
127
.readdirSync(path.join(__dirname, 'rules'))
13-
.filter(
14-
rule => rule !== '__tests__' && rule !== 'util.js' && rule !== 'tsUtils.ts',
15-
)
16-
.map(rule =>
17-
rule.endsWith('js')
18-
? path.basename(rule, '.js')
19-
: path.basename(rule, '.ts'),
20-
)
8+
.filter(rule => rule !== '__tests__' && rule !== 'util.js')
9+
.map(rule => path.basename(rule, '.js'))
2110
.reduce(
22-
(acc, curr) => ({
23-
...acc,
24-
[curr]: interopRequireDefault(require(`./rules/${curr}`)).default,
25-
}),
11+
(acc, curr) => Object.assign(acc, { [curr]: require(`./rules/${curr}`) }),
2612
{},
2713
);
2814

src/rules/__tests__/lowercase-name.test.ts renamed to src/rules/__tests__/lowercase-name.test.js

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
import { RuleTester as ESLintRuleTester } from 'eslint';
2-
import { TSESLint } from '@typescript-eslint/experimental-utils';
3-
import rule from '../lowercase-name';
1+
'use strict';
42

5-
const RuleTester: TSESLint.RuleTester = ESLintRuleTester as any;
3+
const { RuleTester } = require('eslint');
4+
const rule = require('../lowercase-name');
65

76
const ruleTester = new RuleTester({
8-
parser: '@typescript-eslint/parser',
97
parserOptions: {
108
ecmaVersion: 6,
119
},
1210
});
1311

1412
ruleTester.run('lowercase-name', rule, {
1513
valid: [
16-
'randomFunction()',
17-
'foo.bar()',
1814
'it()',
1915
"it(' ', function () {})",
2016
'it(" ", function () {})',
@@ -26,8 +22,6 @@ ruleTester.run('lowercase-name', rule, {
2622
'it("123 foo", function () {})',
2723
'it(42, function () {})',
2824
'it(``)',
29-
'it("")',
30-
'it(42)',
3125
'test()',
3226
"test('foo', function () {})",
3327
'test("foo", function () {})',
@@ -36,8 +30,6 @@ ruleTester.run('lowercase-name', rule, {
3630
'test("123 foo", function () {})',
3731
'test("42", function () {})',
3832
'test(``)',
39-
'test("")',
40-
'test(42)',
4133
'describe()',
4234
"describe('foo', function () {})",
4335
'describe("foo", function () {})',
@@ -47,8 +39,6 @@ ruleTester.run('lowercase-name', rule, {
4739
'describe("42", function () {})',
4840
'describe(function () {})',
4941
'describe(``)',
50-
'describe("")',
51-
'describe(42)',
5242
],
5343

5444
invalid: [
@@ -57,8 +47,7 @@ ruleTester.run('lowercase-name', rule, {
5747
output: "it('foo', function () {})",
5848
errors: [
5949
{
60-
messageId: 'unexpectedLowercase',
61-
data: { method: 'it' },
50+
message: '`it`s should begin with lowercase',
6251
column: 1,
6352
line: 1,
6453
},
@@ -69,8 +58,7 @@ ruleTester.run('lowercase-name', rule, {
6958
output: 'it("foo", function () {})',
7059
errors: [
7160
{
72-
messageId: 'unexpectedLowercase',
73-
data: { method: 'it' },
61+
message: '`it`s should begin with lowercase',
7462
column: 1,
7563
line: 1,
7664
},
@@ -81,8 +69,7 @@ ruleTester.run('lowercase-name', rule, {
8169
output: 'it(`foo`, function () {})',
8270
errors: [
8371
{
84-
messageId: 'unexpectedLowercase',
85-
data: { method: 'it' },
72+
message: '`it`s should begin with lowercase',
8673
column: 1,
8774
line: 1,
8875
},
@@ -93,8 +80,7 @@ ruleTester.run('lowercase-name', rule, {
9380
output: "test('foo', function () {})",
9481
errors: [
9582
{
96-
messageId: 'unexpectedLowercase',
97-
data: { method: 'test' },
83+
message: '`test`s should begin with lowercase',
9884
column: 1,
9985
line: 1,
10086
},
@@ -105,8 +91,7 @@ ruleTester.run('lowercase-name', rule, {
10591
output: 'test("foo", function () {})',
10692
errors: [
10793
{
108-
messageId: 'unexpectedLowercase',
109-
data: { method: 'test' },
94+
message: '`test`s should begin with lowercase',
11095
column: 1,
11196
line: 1,
11297
},
@@ -117,8 +102,7 @@ ruleTester.run('lowercase-name', rule, {
117102
output: 'test(`foo`, function () {})',
118103
errors: [
119104
{
120-
messageId: 'unexpectedLowercase',
121-
data: { method: 'test' },
105+
message: '`test`s should begin with lowercase',
122106
column: 1,
123107
line: 1,
124108
},
@@ -129,8 +113,7 @@ ruleTester.run('lowercase-name', rule, {
129113
output: "describe('foo', function () {})",
130114
errors: [
131115
{
132-
messageId: 'unexpectedLowercase',
133-
data: { method: 'describe' },
116+
message: '`describe`s should begin with lowercase',
134117
column: 1,
135118
line: 1,
136119
},
@@ -141,8 +124,7 @@ ruleTester.run('lowercase-name', rule, {
141124
output: 'describe("foo", function () {})',
142125
errors: [
143126
{
144-
messageId: 'unexpectedLowercase',
145-
data: { method: 'describe' },
127+
message: '`describe`s should begin with lowercase',
146128
column: 1,
147129
line: 1,
148130
},
@@ -153,8 +135,7 @@ ruleTester.run('lowercase-name', rule, {
153135
output: 'describe(`foo`, function () {})',
154136
errors: [
155137
{
156-
messageId: 'unexpectedLowercase',
157-
data: { method: 'describe' },
138+
message: '`describe`s should begin with lowercase',
158139
column: 1,
159140
line: 1,
160141
},
@@ -165,8 +146,7 @@ ruleTester.run('lowercase-name', rule, {
165146
output: 'describe(`some longer description`, function () {})',
166147
errors: [
167148
{
168-
messageId: 'unexpectedLowercase',
169-
data: { method: 'describe' },
149+
message: '`describe`s should begin with lowercase',
170150
column: 1,
171151
line: 1,
172152
},

src/rules/__tests__/no-jest-import.test.ts renamed to src/rules/__tests__/no-jest-import.test.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
import { RuleTester as ESLintRuleTester } from 'eslint';
2-
import { TSESLint } from '@typescript-eslint/experimental-utils';
3-
import rule from '../no-jest-import';
1+
'use strict';
42

5-
const RuleTester: TSESLint.RuleTester = ESLintRuleTester as any;
6-
7-
const ruleTester = new RuleTester({
8-
parser: '@typescript-eslint/parser',
9-
parserOptions: {
10-
ecmaVersion: 6,
11-
},
12-
});
3+
const rule = require('../no-jest-import.js');
4+
const { RuleTester } = require('eslint');
5+
const ruleTester = new RuleTester();
6+
const message = `Jest is automatically in scope. Do not import "jest", as Jest doesn't export anything.`;
137

148
ruleTester.run('no-jest-import', rule, {
159
valid: [
@@ -28,7 +22,7 @@ ruleTester.run('no-jest-import', rule, {
2822
{
2923
endColumn: 15,
3024
column: 9,
31-
messageId: 'unexpectedImport',
25+
message,
3226
},
3327
],
3428
},
@@ -38,8 +32,8 @@ ruleTester.run('no-jest-import', rule, {
3832
errors: [
3933
{
4034
endColumn: 24,
41-
column: 18,
42-
messageId: 'unexpectedImport',
35+
column: 1,
36+
message,
4337
},
4438
],
4539
},
@@ -49,7 +43,7 @@ ruleTester.run('no-jest-import', rule, {
4943
{
5044
endColumn: 26,
5145
column: 20,
52-
messageId: 'unexpectedImport',
46+
message,
5347
},
5448
],
5549
},
@@ -59,8 +53,8 @@ ruleTester.run('no-jest-import', rule, {
5953
errors: [
6054
{
6155
endColumn: 34,
62-
column: 28,
63-
messageId: 'unexpectedImport',
56+
column: 1,
57+
message,
6458
},
6559
],
6660
},
@@ -71,7 +65,7 @@ ruleTester.run('no-jest-import', rule, {
7165
{
7266
endColumn: 28,
7367
column: 22,
74-
messageId: 'unexpectedImport',
68+
message,
7569
},
7670
],
7771
},

0 commit comments

Comments
 (0)