Skip to content

Commit 491e8f0

Browse files
feat(core): drop support for HTTP URL imports (#63)
1 parent cf98925 commit 491e8f0

6 files changed

Lines changed: 0 additions & 64 deletions

File tree

README.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ TSSLint aims to seamlessly integrate with tsserver to minimize unnecessary overh
3232
- Writing config in typescript.
3333
- Direct support for meta framework files based on TS Plugin without a parser. (e.g., Vue, MDX)
3434
- Pure ESM.
35-
- Supports HTTP URL import, no need to add dependencies in package.json.
3635
- Designed to allow simple, direct access to rule source code without an intermediary layer.
3736

3837
## Usage
@@ -118,27 +117,6 @@ After saving the config file, you will notice that `console.log` is now reportin
118117

119118
> Full example: https://github.com/johnsoncodehk/tsslint/tree/master/fixtures/define-a-rule
120119
121-
### Import Rules from HTTP URL
122-
123-
You can directly import rules from other repositories using HTTP URLs. This allows you to easily share and reuse rules across different projects.
124-
125-
Here's an example of how to import a rule from a HTTP URL:
126-
127-
```diff
128-
import { defineConfig } from '@tsslint/config';
129-
130-
export default defineConfig({
131-
rules: {
132-
'no-console': (await import('./rules/noConsoleRule.ts')).create(),
133-
+ 'no-alert': (await import('https://gist.githubusercontent.com/johnsoncodehk/55a4c45a5a35fc30b83de20507fb2bdc/raw/5f9c9a67ace76c0a77995fd71c3fb4fb504a40c8/TSSLint_noAlertRule.ts')).create(),
134-
},
135-
});
136-
```
137-
138-
In this example, the `no-alert` rule is imported from a file hosted on GitHub. After saving the config file, you will notice that `alert()` calls are now reporting errors in the editor.
139-
140-
> Full example: https://github.com/johnsoncodehk/tsslint/tree/master/fixtures/http-import
141-
142120
### Modify the Error
143121

144122
While you cannot directly configure the severity of a rule, you can modify the reported errors through the `resolveDiagnostics()` API in the config file. This allows you to customize the severity of specific rules and even add additional errors.

fixtures/http-import/fixture.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

fixtures/http-import/tsconfig.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

fixtures/http-import/tsslint.config.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/core/lib/build.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ export function buildConfig(
2727
},
2828
false,
2929
createHash,
30-
spinner,
31-
stopSnipper
3230
);
3331
} catch (e) {
3432
stopSnipper?.('Failed to build ' + configFileDisplayPath + ' in ' + (Date.now() - buildStart) + 'ms', 1);

packages/core/lib/watch.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ export async function watchConfig(
88
onBuild: (config: string | undefined, result: esbuild.BuildResult) => void,
99
watch = true,
1010
createHash: (path: string) => string = btoa,
11-
// @ts-expect-error
12-
spinner?: ReturnType<typeof import('@clack/prompts').spinner>,
13-
stopSnipper?: (message: string, code?: number) => void
1411
) {
1512
const outDir = getDotTsslintPath(configFilePath);
1613
const outFileName = createHash(_path.relative(outDir, configFilePath)) + '.mjs';
@@ -32,32 +29,6 @@ export async function watchConfig(
3229
plugins: [{
3330
name: 'tsslint',
3431
setup(build) {
35-
build.onResolve({ filter: /^https?:\/\// }, async ({ path: importUrl }) => {
36-
const cachePath = _path.join(outDir, importUrl.split('://')[0], ...importUrl.split('://')[1].split('/'));
37-
if (!fs.existsSync(cachePath)) {
38-
const start = Date.now();
39-
spinner?.message('Downloading ' + importUrl);
40-
const response = await fetch(importUrl);
41-
if (!response.ok) {
42-
throw new Error(`Failed to load ${importUrl}`);
43-
}
44-
stopSnipper?.('Downloaded ' + importUrl + ' in ' + (Date.now() - start) + 'ms');
45-
const text = await response.text();
46-
fs.mkdirSync(_path.dirname(cachePath), { recursive: true });
47-
fs.writeFileSync(cachePath, text, 'utf8');
48-
}
49-
if (isTsFile(cachePath)) {
50-
return {
51-
path: cachePath,
52-
external: false,
53-
};
54-
} else {
55-
return {
56-
path: url.pathToFileURL(cachePath).toString(),
57-
external: true,
58-
};
59-
}
60-
});
6132
build.onResolve({ filter: /.*/ }, ({ path, resolveDir }) => {
6233
if (!isTsFile(path)) {
6334
try {

0 commit comments

Comments
 (0)