Skip to content

Commit dd86d41

Browse files
committed
cleanup for jest
1 parent 3a7d4eb commit dd86d41

File tree

92 files changed

+3359
-3688
lines changed

Some content is hidden

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

92 files changed

+3359
-3688
lines changed

.coveralls.yml

-2
This file was deleted.

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ test/fixtures/cycles/flow-typeof.js
1010
test/fixtures/flowtypes.js
1111
# unexpected - TODO: report to babel
1212
test/fixtures/jsx.js
13+
!/.*.js

.eslintrc

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"plugin:prettier/recommended"
1010
],
1111
"env": {
12-
"es6": true,
12+
"es2023": true,
1313
"node": true
1414
},
1515
"parserOptions": {
@@ -20,9 +20,14 @@
2020
}
2121
},
2222
"rules": {
23+
"no-var": "error",
2324
"i/order": [
2425
"error",
2526
{
27+
"alphabetize": {
28+
"order": "asc",
29+
"orderImportKind": "asc"
30+
},
2631
"newlines-between": "always"
2732
}
2833
],
@@ -48,6 +53,13 @@
4853
{
4954
"files": "test/fixtures/**/*.js",
5055
"rules": {
56+
"no-undef": "off",
57+
"no-unused-modules": "off",
58+
"no-unused-vars": "off",
59+
"i/default": "off",
60+
"i/export": "off",
61+
"i/named": "off",
62+
"i/no-duplicates": "off",
5163
"unicorn/no-empty-file": "off"
5264
}
5365
}

babel.config.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
/**
2-
* @type {import('@babel/core').TransformOptions}
3-
*/
41
module.exports = {
52
presets: [
3+
'@babel/flow',
64
[
75
'@1stg',
86
{
97
modules: 'commonjs',
8+
typescript: true,
109
},
1110
],
1211
],
1312
plugins: ['@babel/proposal-export-default-from'],
13+
targets: {
14+
node: 'current',
15+
},
1416
overrides: [
1517
{
1618
test: './test/fixtures/jsx.js',

docs/rules/no-restricted-paths.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ and the current configuration is set to:
7979
{
8080
"zones": [
8181
{
82-
"target": "./tests/files/restricted-paths/server/one",
83-
"from": "./tests/files/restricted-paths/server",
82+
"target": "./test/fixtures/restricted-paths/server/one",
83+
"from": "./test/fixtures/restricted-paths/server",
8484
"except": ["./one"]
8585
}
8686
]
@@ -119,8 +119,8 @@ and the current configuration is set to:
119119
{
120120
"zones": [
121121
{
122-
"target": "./tests/files/restricted-paths/client/!(sub-module)/**/*",
123-
"from": "./tests/files/restricted-paths/client/sub-module/**/*"
122+
"target": "./test/fixtures/restricted-paths/client/!(sub-module)/**/*",
123+
"from": "./test/fixtures/restricted-paths/client/sub-module/**/*"
124124
}
125125
]
126126
}
@@ -162,12 +162,12 @@ and the current configuration is set to:
162162
"zones": [
163163
{
164164
"target": [
165-
"./tests/files/restricted-paths/two/*",
166-
"./tests/files/restricted-paths/three/*"
165+
"./test/fixtures/restricted-paths/two/*",
166+
"./test/fixtures/restricted-paths/three/*"
167167
],
168168
"from": [
169-
"./tests/files/restricted-paths/one",
170-
"./tests/files/restricted-paths/three"
169+
"./test/fixtures/restricted-paths/one",
170+
"./test/fixtures/restricted-paths/three"
171171
]
172172
}
173173
]

package.json

+24-3
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,39 @@
3636
"export"
3737
],
3838
"scripts": {
39-
"build": "rimraf lib && babel src -d lib",
39+
"build": "rimraf lib && babel src -s -d lib",
4040
"lint": "yarn build && eslint . --cache",
4141
"prepare": "patch-package && yarn-deduplicate -s fewer",
42+
"test": "jest",
4243
"update:eslint-docs": "yarn build && eslint-doc-generator --rule-doc-title-format prefix-name --rule-doc-section-options false --rule-list-split meta.docs.category --ignore-config stage-0 --config-emoji recommended,☑️"
4344
},
4445
"peerDependencies": {
4546
"eslint": "^7.2.0 || ^8"
4647
},
4748
"dependencies": {
4849
"debug": "^4.3.4",
50+
"doctrine": "^3.0.0",
4951
"enhanced-resolve": "^5.15.0",
5052
"get-tsconfig": "^4.7.2",
5153
"is-glob": "^4.0.3",
52-
"minimatch": "^3.1.2",
53-
"semver": "^7.5.4"
54+
"minimatch": "^3.1.2"
5455
},
5556
"devDependencies": {
5657
"@1stg/babel-preset": "^4.0.0",
5758
"@1stg/prettier-config": "^4.0.1",
59+
"@angular-eslint/template-parser": "^17.2.0",
5860
"@babel/cli": "^7.23.4",
5961
"@babel/core": "^7.23.7",
6062
"@babel/eslint-parser": "^7.23.3",
6163
"@babel/plugin-proposal-export-default-from": "^7.23.3",
64+
"@babel/preset-flow": "^7.23.3",
6265
"@babel/preset-react": "^7.23.3",
66+
"@eslint/import-test-order-redirect-scoped": "link:./test/fixtures/order-redirect-scoped",
67+
"@test-scope/some-module": "link:./test/fixtures/symlinked-module",
6368
"@types/eslint": "^8.56.2",
6469
"@types/eslint7": "npm:@types/eslint@7",
6570
"@types/jest": "^29.5.11",
71+
"@typescript-eslint/parser": "^6.19.0",
6672
"eslint": "^8.56.0",
6773
"eslint-config-prettier": "^9.1.0",
6874
"eslint-module-utils": "link:utils",
@@ -76,6 +82,21 @@
7682
"patch-package": "^8.0.0",
7783
"prettier": "^3.2.4",
7884
"rimraf": "^5.0.5",
85+
"semver": "^7.5.4",
86+
"typescript": "^5.3.3",
7987
"yarn-deduplicate": "^6.0.2"
88+
},
89+
"jest": {
90+
"collectCoverage": true,
91+
"modulePathIgnorePatterns": [
92+
"<rootDir>/test/fixtures/with-syntax-error"
93+
],
94+
"moduleNameMapper": {
95+
"^core/(.+)$": "<rootDir>/src/core/$1",
96+
"^rules/(.+)$": "<rootDir>/src/rules/$1"
97+
},
98+
"testMatch": [
99+
"<rootDir>/test/src/**/*.spec.js"
100+
]
80101
}
81102
}

patches/cliui+8.0.1.patch

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/node_modules/cliui/build/index.cjs b/node_modules/cliui/build/index.cjs
2+
index 82126b6..009c42d 100644
3+
--- a/node_modules/cliui/build/index.cjs
4+
+++ b/node_modules/cliui/build/index.cjs
5+
@@ -289,7 +289,7 @@ function cliui(opts, _mixin) {
6+
7+
// Bootstrap cliui with CommonJS dependencies:
8+
const stringWidth = require('string-width');
9+
-const stripAnsi = require('strip-ansi');
10+
+const stripAnsi = require('strip-ansi-cjs');
11+
const wrap = require('wrap-ansi');
12+
function ui(opts) {
13+
return cliui(opts, {

patches/string-length+4.0.2.patch

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
diff --git a/node_modules/string-length/index.js b/node_modules/string-length/index.js
2+
index c2589a2..3040f0a 100644
3+
--- a/node_modules/string-length/index.js
4+
+++ b/node_modules/string-length/index.js
5+
@@ -1,5 +1,5 @@
6+
'use strict';
7+
-const stripAnsi = require('strip-ansi');
8+
+const stripAnsi = require('strip-ansi-cjs');
9+
const charRegex = require('char-regex');
10+
11+
const stringLength = string => {

patches/string-width+4.2.3.patch

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
diff --git a/node_modules/string-width/index.js b/node_modules/string-width/index.js
2+
index f4d261a..7ea642a 100644
3+
--- a/node_modules/string-width/index.js
4+
+++ b/node_modules/string-width/index.js
5+
@@ -1,5 +1,5 @@
6+
'use strict';
7+
-const stripAnsi = require('strip-ansi');
8+
+const stripAnsi = require('strip-ansi-cjs');
9+
const isFullwidthCodePoint = require('is-fullwidth-code-point');
10+
const emojiRegex = require('emoji-regex');
11+

patches/wrap-ansi+7.0.0.patch

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/node_modules/wrap-ansi/index.js b/node_modules/wrap-ansi/index.js
2+
index d502255..1ed059c 100755
3+
--- a/node_modules/wrap-ansi/index.js
4+
+++ b/node_modules/wrap-ansi/index.js
5+
@@ -1,6 +1,6 @@
6+
'use strict';
7+
const stringWidth = require('string-width');
8+
-const stripAnsi = require('strip-ansi');
9+
+const stripAnsi = require('strip-ansi-cjs');
10+
const ansiStyles = require('ansi-styles');
11+
12+
const ESCAPES = new Set([

src/ExportMap.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import fs from 'fs'
22
import path from 'path'
33

4-
import doctrine from 'doctrine'
54
import debug from 'debug'
5+
import doctrine from 'doctrine'
66
import { SourceCode } from 'eslint'
77
import { getTsconfig } from 'get-tsconfig'
88

9+
import { hashObject } from 'eslint-module-utils/hash'
10+
import isIgnored, { hasValidExtension } from 'eslint-module-utils/ignore'
911
import parse from 'eslint-module-utils/parse'
10-
import visit from 'eslint-module-utils/visit'
1112
import resolve from 'eslint-module-utils/resolve'
12-
import isIgnored, { hasValidExtension } from 'eslint-module-utils/ignore'
13-
import { hashObject } from 'eslint-module-utils/hash'
1413
import * as unambiguous from 'eslint-module-utils/unambiguous'
14+
import visit from 'eslint-module-utils/visit'
1515

1616
const includes = Function.bind.bind(Function.prototype.call)(
1717
Array.prototype.includes,
@@ -729,7 +729,7 @@ ExportMap.parse = function (filepath, content, context) {
729729
switch (n.declaration.type) {
730730
case 'FunctionDeclaration':
731731
case 'ClassDeclaration':
732-
case 'TypeAlias': // flowtype with babel-eslint parser
732+
case 'TypeAlias': // flowtype with @babel/eslint-parser
733733
case 'InterfaceDeclaration':
734734
case 'DeclareFunction':
735735
case 'TSDeclareFunction':

src/core/importType.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import path from 'path'
21
import { Module } from 'module'
2+
import path from 'path'
33

44
import { getContextPackagePath } from './packagePath'
55

src/rules/export.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ module.exports = {
241241
const parent = getParent(node)
242242

243243
let any = false
244-
for (const name of remoteExports.keys()) {
244+
for (const name of Object.keys(remoteExports)) {
245245
if (name !== 'default') {
246246
any = true // poor man's filter
247247
addNamed(name, node, parent)

src/rules/extensions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import path from 'path'
33
import { isBuiltIn, isExternalModule, isScoped } from '../core/importType'
44
import docsUrl from '../docsUrl'
55

6-
import resolve from 'eslint-module-utils/resolve'
76
import moduleVisitor from 'eslint-module-utils/moduleVisitor'
7+
import resolve from 'eslint-module-utils/resolve'
88

99
const enumValues = { enum: ['always', 'ignorePackages', 'never'] }
1010
const patternProperties = {

src/rules/namespace.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Exports from '../ExportMap'
2-
import importDeclaration from '../importDeclaration'
32
import docsUrl from '../docsUrl'
3+
import importDeclaration from '../importDeclaration'
44

55
import declaredScope from 'eslint-module-utils/declaredScope'
66

src/rules/no-extraneous-dependencies.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { getFilePackageName } from '../core/packagePath'
88
import docsUrl from '../docsUrl'
99

1010
import moduleVisitor from 'eslint-module-utils/moduleVisitor'
11-
import resolve from 'eslint-module-utils/resolve'
1211
import pkgUp from 'eslint-module-utils/pkgUp'
12+
import resolve from 'eslint-module-utils/resolve'
1313

1414
const depFieldCache = new Map()
1515

src/rules/no-internal-modules.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import minimatch from 'minimatch'
33
import importType from '../core/importType'
44
import docsUrl from '../docsUrl'
55

6-
import resolve from 'eslint-module-utils/resolve'
76
import moduleVisitor from 'eslint-module-utils/moduleVisitor'
7+
import resolve from 'eslint-module-utils/resolve'
88

99
// minimatch patterns are expected to use / path separators, like import
1010
// statements, so normalize paths to use the same

src/rules/no-named-as-default-member.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Exports from '../ExportMap'
2-
import importDeclaration from '../importDeclaration'
32
import docsUrl from '../docsUrl'
3+
import importDeclaration from '../importDeclaration'
44

55
//------------------------------------------------------------------------------
66
// Rule Definition

src/rules/no-named-as-default.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Exports from '../ExportMap'
2-
import importDeclaration from '../importDeclaration'
32
import docsUrl from '../docsUrl'
3+
import importDeclaration from '../importDeclaration'
44

55
module.exports = {
66
meta: {

src/rules/no-relative-packages.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import path from 'path'
33
import importType from '../core/importType'
44
import docsUrl from '../docsUrl'
55

6-
import readPkgUp from 'eslint-module-utils/readPkgUp'
7-
import resolve from 'eslint-module-utils/resolve'
86
import moduleVisitor, {
97
makeOptionsSchema,
108
} from 'eslint-module-utils/moduleVisitor'
9+
import readPkgUp from 'eslint-module-utils/readPkgUp'
10+
import resolve from 'eslint-module-utils/resolve'
1111

1212
/** @param {string} filePath */
1313
function toPosixPath(filePath) {

src/rules/no-relative-parent-imports.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'path'
22

3-
import docsUrl from '../docsUrl'
43
import importType from '../core/importType'
4+
import docsUrl from '../docsUrl'
55

66
import moduleVisitor, {
77
makeOptionsSchema,

src/rules/no-restricted-paths.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import path from 'path'
33
import isGlob from 'is-glob'
44
import { Minimatch } from 'minimatch'
55

6-
import docsUrl from '../docsUrl'
76
import importType from '../core/importType'
7+
import docsUrl from '../docsUrl'
88

99
import moduleVisitor from 'eslint-module-utils/moduleVisitor'
1010
import resolve from 'eslint-module-utils/resolve'

src/rules/no-self-import.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import docsUrl from '../docsUrl'
22

3-
import resolve from 'eslint-module-utils/resolve'
43
import moduleVisitor from 'eslint-module-utils/moduleVisitor'
4+
import resolve from 'eslint-module-utils/resolve'
55

66
function isImportingSelf(context, node, requireName) {
77
const filePath = context.getPhysicalFilename

src/rules/no-unresolved.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import docsUrl from '../docsUrl'
22

3-
import resolve, {
4-
CASE_SENSITIVE_FS,
5-
fileExistsWithCaseSync,
6-
} from 'eslint-module-utils/resolve'
73
import ModuleCache from 'eslint-module-utils/ModuleCache'
84
import moduleVisitor, {
95
makeOptionsSchema,
106
} from 'eslint-module-utils/moduleVisitor'
7+
import resolve, {
8+
CASE_SENSITIVE_FS,
9+
fileExistsWithCaseSync,
10+
} from 'eslint-module-utils/resolve'
1111

1212
module.exports = {
1313
meta: {

src/rules/no-unused-modules.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import Exports, { recursivePatternCapture } from '../ExportMap'
44
import docsUrl from '../docsUrl'
55

66
import { getFileExtensions } from 'eslint-module-utils/ignore'
7+
import readPkgUp from 'eslint-module-utils/readPkgUp'
78
import resolve from 'eslint-module-utils/resolve'
89
import visit from 'eslint-module-utils/visit'
9-
import readPkgUp from 'eslint-module-utils/readPkgUp'
1010

1111
const { values } = Object
1212
const includes = Function.bind.bind(Function.prototype.call)(

0 commit comments

Comments
 (0)