Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitec30c73

Browse files
feat: add "eslint/universal" to exportLinter (#18883)
* feat: add "eslint/universal" to export `Linter`fixes#18715* fix: add lib/universal.js* feat: add typings* chore: add tests for "eslint/universal" types* Update lib/types/universal.d.tsCo-authored-by: Francesco Trotta <github@fasttime.org>* chore: update types tests---------Co-authored-by: Francesco Trotta <github@fasttime.org>
1 parentc591da6 commitec30c73

File tree

6 files changed

+44
-1
lines changed

6 files changed

+44
-1
lines changed

‎eslint.config.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ module.exports = [
200200
{
201201
name:"eslint/lib",
202202
files:["lib/*.js"],
203-
ignores:["lib/unsupported-api.js"],
203+
ignores:["lib/unsupported-api.js","lib/universal.js"],
204204
rules:{
205205
"n/no-restricted-require":["error",[
206206
...createInternalFilesPatterns()

‎lib/types/universal.d.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
*@fileoverview typings for "eslint/universal" module
3+
*@author 唯然<weiran.zsd@outlook.com>
4+
*/
5+
6+
export{Linter}from"./index";

‎lib/universal.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
*@fileoverview exports for browsers
3+
*@author 唯然<weiran.zsd@outlook.com>
4+
*/
5+
6+
"use strict";
7+
8+
const{ Linter}=require("./linter/linter");
9+
10+
module.exports={ Linter};

‎package.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
},
2121
"./rules": {
2222
"types":"./lib/types/rules/index.d.ts"
23+
},
24+
"./universal": {
25+
"types":"./lib/types/universal.d.ts",
26+
"default":"./lib/universal.js"
2327
}
2428
},
2529
"scripts": {

‎tests/lib/types/types.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import{AST,ESLint,Linter,loadESLint,Rule,RuleTester,Scope,SourceCode}from"eslint";
2929
import{ESLintRules}from"eslint/rules";
30+
import{LinterasESLinter}from"eslint/universal";
3031
import{
3132
builtinRules,
3233
FileEnumerator,
@@ -579,6 +580,7 @@ rule = {
579580
// #region Linter
580581

581582
constlinter=newLinter();
583+
consteslinter=newESLinter();
582584

583585
linter.version;
584586

‎tests/lib/universal.js‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
*@fileoverview Tests for "eslint/universal".
3+
*@author 唯然<weiran.zsd@outlook.com>
4+
*/
5+
6+
"use strict";
7+
constassert=require("node:assert/strict");
8+
9+
describe("universal",()=>{
10+
it("should have Linter exported",()=>{
11+
const{ Linter}=require("eslint/universal");
12+
13+
assert.ok(Linter);
14+
assert.ok(typeofLinter==="function");
15+
16+
17+
constlinter=newLinter();
18+
19+
assert.ok(linter);
20+
});
21+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp