Skip to content

Commit 3fb07f9

Browse files
authored
ESLint import resolver require package (#2)
* chore: migrate to monoweave * chore: initial release
1 parent 12d0fdd commit 3fb07f9

File tree

14 files changed

+1634
-1316
lines changed

14 files changed

+1634
-1316
lines changed

.github/workflows/ci.yaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,5 @@ jobs:
6161
steps:
6262
- uses: noahnu/.github/.github/actions/setup-node@main
6363

64-
- name: Post Monodeploy Preview
65-
uses: noahnu/.github/.github/actions/post-monodeploy-preview@main
66-
with:
67-
token: ${{ secrets.GITHUB_TOKEN }}
64+
- name: Post Preview
65+
uses: monoweave/github-action-preview@95e30cfa4b8dfb69cb8d18050ef05a207c6f8551 # v1.1.0

.monoweave/3407b872.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
"@noahnu/eslint-import-resolver-require": patch
3+
---
4+
Initial release of @noahnu/eslint-import-resolver-require.

.yarn/sdks/eslint/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint",
3-
"version": "8.53.0-sdk",
3+
"version": "8.57.0-sdk",
44
"main": "./lib/api.js",
55
"type": "commonjs",
66
"bin": {

monodeploy.config.js

-19
This file was deleted.

monoweave.config.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @ts-check
2+
3+
/** @type {import('@monoweave/types').MonoweaveConfigFile} */
4+
const config = {
5+
preset: 'monoweave/preset-manual',
6+
maxConcurrentWrites: 1,
7+
changesetIgnorePatterns: ['**/*.test.ts'],
8+
commitIgnorePatterns: ['\\[skip-ci\\]'],
9+
}
10+
11+
module.exports = config

package.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
"workspaces": [
1919
"packages/*"
2020
],
21-
"packageManager": "yarn@4.0.2",
21+
"packageManager": "yarn@4.1.1+sha256.f3cc0eda8e5560e529c7147565b30faa43b4e472d90e8634d7134a37c7f59781",
2222
"devDependencies": {
2323
"@jest/types": "^29.6.3",
24-
"@monodeploy/plugin-github": "^2.0.1",
25-
"@monodeploy/types": "^5.0.1",
24+
"@monoweave/plugin-github": "^2.0.7",
2625
"@tophat/commitizen-adapter": "^1.0.2",
2726
"@tophat/commitlint-config": "^1.0.2",
2827
"@tophat/conventional-changelog-config": "^1.0.1",
@@ -33,7 +32,7 @@
3332
"@types/node": "^20",
3433
"@typescript-eslint/eslint-plugin": "^6.18.1",
3534
"@typescript-eslint/parser": "^6.18.1",
36-
"@yarnpkg/core": "^4.0.2",
35+
"@yarnpkg/core": "^4.0.3",
3736
"@yarnpkg/sdks": "^3.1.0",
3837
"@yarnpkg/types": "^4.0.0",
3938
"commitizen": "^4.3.0",
@@ -51,7 +50,6 @@
5150
"jest": "^29.7.0",
5251
"jest-junit": "^16.0.0",
5352
"lint-staged": "^15.1.0",
54-
"monodeploy": "^5.0.1",
5553
"prettier": "^3.1.0",
5654
"ts-jest": "^29.1.1",
5755
"ts-node": "^10.9.1",
@@ -69,6 +67,10 @@
6967
"types:watch": "tsc --noEmit --emitDeclarationOnly false --pretty --watch",
7068
"workspace:build": "rm -rf $0/lib $0/.tmp && tsc -p $0/tsconfig.build.json",
7169
"workspace:clean": "rm -rf $0/lib $0/.tmp && find $0/src -name '*.js' -type f -delete",
72-
"release": "monodeploy --config-file monodeploy.config.js --log-level 0 --plugins @monodeploy/plugin-github"
70+
"release": "monoweave --log-level 0 --plugins @monoweave/plugin-github"
71+
},
72+
"dependencies": {
73+
"@monoweave/cli": "^1.1.0",
74+
"@monoweave/types": "^1.1.0"
7375
}
7476
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# @noahnu/eslint-import-resolver-require
2+
3+
The simplest eslint import resolver plugin. All it does is expose node's require.
4+
5+
## Usage
6+
7+
```yml
8+
# .eslintrc.yml
9+
settings:
10+
import/resolver: "@noahnu/eslint-import-resolver-require"
11+
```
12+
13+
```js
14+
// .eslintrc.js
15+
module.exports = {
16+
settings: {
17+
'import/resolver': {
18+
'@noahnu/eslint-import-resolver': {}
19+
}
20+
}
21+
}
22+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "@noahnu/eslint-import-resolver-require",
3+
"version": "0.0.1",
4+
"repository": {
5+
"type": "git",
6+
"url": "https://github.com/noahnu/nodejs-tools.git",
7+
"directory": "packages/eslint-import-resolver-require"
8+
},
9+
"license": "MIT",
10+
"author": {
11+
"name": "noahnu",
12+
"email": "[email protected]",
13+
"url": "https://noahnu.com"
14+
},
15+
"scripts": {
16+
"clean": "run workspace:clean \"$(pwd)\"",
17+
"prepack": "run workspace:build \"$(pwd)\"",
18+
"run-local": "run -T ts-node --transpileOnly ./src/bin.ts"
19+
},
20+
"main": "./src/index.ts",
21+
"publishConfig": {
22+
"registry": "https://registry.npmjs.org/",
23+
"access": "public",
24+
"bin": "./lib/bin.js",
25+
"main": "./lib/index.js",
26+
"types": "./lib/index.d.ts"
27+
},
28+
"files": [
29+
"lib"
30+
],
31+
"devDependencies": {
32+
"@types/eslint": "^8.44.3",
33+
"@types/jest": "^29.5.5",
34+
"@types/node": "^18.15.11",
35+
"eslint": "^8.50.0"
36+
},
37+
"peerDependencies": {
38+
"eslint-plugin-import": ">= 2.0.0"
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { builtinModules } from 'module'
2+
import path from 'path'
3+
4+
const builtins = new Set(builtinModules)
5+
6+
const resolve = (source: string, file: string) => {
7+
if (builtins.has(source)) {
8+
return { found: true }
9+
}
10+
11+
try {
12+
let moduleId = require.resolve(source, { paths: [path.dirname(file)] })
13+
if (process.versions.pnp && moduleId.includes('__virtual__')) {
14+
// eslint-disable-next-line @typescript-eslint/no-var-requires
15+
moduleId = require('pnpapi').resolveVirtual(moduleId)
16+
}
17+
return { found: true, path: moduleId }
18+
} catch (err) {
19+
return { found: false }
20+
}
21+
}
22+
23+
export = {
24+
interfaceVersion: 2,
25+
resolve,
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"rootDir": "./src",
5+
"tsBuildInfoFile": "./.tmp/.tsbuildinfo",
6+
},
7+
"include": ["./src"],
8+
"exclude": ["./src/**/*.test.ts"]
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"declarationDir": "./lib",
5+
"outDir": "./lib"
6+
},
7+
"include": ["./src"],
8+
}

packages/unused-files/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
<!-- MONODEPLOY:BELOW -->
3+
<!-- MONOWEAVE:BELOW -->
44

55
## [0.0.1](https://github.com/noahnu/nodejs-tools/compare/@noahnu/[email protected]...@noahnu/[email protected]) "@noahnu/unused-files" (2024-01-15)<a name="0.0.1"></a>
66

script/bootstrap

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
# shellcheck disable=SC1091
4+
command -v nvm >/dev/null || . "${NVM_DIR:-"$HOME/.nvm"}"/nvm.sh;
5+
nvm use --silent;
6+
7+
yarn;

0 commit comments

Comments
 (0)