Skip to content

Commit

Permalink
add danger_string_usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ityuany committed Jul 5, 2024
1 parent 367311e commit 25f8d19
Show file tree
Hide file tree
Showing 44 changed files with 701 additions and 38 deletions.
14 changes: 13 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{
"cSpell.words": [
"antd",
"bootcdn",
"bootcss",
"napi",
"threadpool"
]
],
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions __test__/danger_string/index.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import test from "ava";
import { getUsageOfDangerStrings } from "../../index.js";
import { fileURLToPath } from "node:url";
import { dirname } from "node:path";

// 获取当前文件的路径
const __filename = fileURLToPath(import.meta.url);

test("getUsageOfDangerStrings", (t) => {
const response = getUsageOfDangerStrings(["bootcss.com", "bootcdn.com", "polyfill.com", "polyfill.io"], {
cwd: dirname(__filename),
});
t.snapshot(response.sort((x) => x.filePath));
});
61 changes: 61 additions & 0 deletions __test__/danger_string/index.spec.mjs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Snapshot report for `__test__/danger_string/index.spec.mjs`

The actual snapshot is saved in `index.spec.mjs.snap`.

Generated by [AVA](https://avajs.dev).

## getUsageOfDangerStrings

> Snapshot 1
[
{
end: 21,
filePath: '/Users/10015448/GitRepository/source-code-diagnosis/__test__/danger_string/features/demo3.js',
matchDangerString: 'bootcss.com',
rawValue: 'bootcss.com',
start: 8,
},
{
end: 27,
filePath: '/Users/10015448/GitRepository/source-code-diagnosis/__test__/danger_string/features/demo5.js',
matchDangerString: 'bootcss.com',
rawValue: 'bootcss.com/hello',
start: 8,
},
{
end: 25,
filePath: '/Users/10015448/GitRepository/source-code-diagnosis/__test__/danger_string/features/demo1.js',
matchDangerString: 'bootcss.com',
rawValue: 'bootcss.com',
start: 12,
},
{
end: 21,
filePath: '/Users/10015448/GitRepository/source-code-diagnosis/__test__/danger_string/features/demo4.js',
matchDangerString: 'bootcss.com',
rawValue: 'bootcss.com',
start: 8,
},
{
end: 19,
filePath: '/Users/10015448/GitRepository/source-code-diagnosis/__test__/danger_string/features/demo6.js',
matchDangerString: 'bootcss.com',
rawValue: 'bootcss.com/hello',
start: 0,
},
{
end: 13,
filePath: '/Users/10015448/GitRepository/source-code-diagnosis/__test__/danger_string/features/demo2.js',
matchDangerString: 'bootcss.com',
rawValue: 'bootcss.com',
start: 0,
},
{
end: 86,
filePath: '/Users/10015448/GitRepository/source-code-diagnosis/__test__/danger_string/features/demo7.jsx',
matchDangerString: 'bootcss.com',
rawValue: 'http://bootcss.com/hello',
start: 60,
},
]
Binary file added __test__/danger_string/index.spec.mjs.snap
Binary file not shown.
15 changes: 0 additions & 15 deletions __test__/index.spec.mjs

This file was deleted.

1 change: 1 addition & 0 deletions __test__/module_member_usage/features/demo1/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import { Button } from "antd"
15 changes: 15 additions & 0 deletions __test__/module_member_usage/features/demo10/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as antd from "antd"
import { deepClone } from "lodash"

function App(props) {

useEffect(() => {
let x = deepClone(props.user)
},[])

return (
<div>
<antd.Button />
</div>
)
}
14 changes: 14 additions & 0 deletions __test__/module_member_usage/features/demo11/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as antd from "antd"

function App(props) {

useEffect(() => {
let x = deepClone(props.user)
},[])

return (
<div>
<antd.Button />
</div>
)
}
4 changes: 4 additions & 0 deletions __test__/module_member_usage/features/demo12/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as antd from "antd"


React.createElement(antd.Button, null)
12 changes: 12 additions & 0 deletions __test__/module_member_usage/features/demo13/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Grid as G } from 'antd';


function A() {
return <G>xx</G>
}

function B() {
return <G>xx</G>
}

G.a;
10 changes: 10 additions & 0 deletions __test__/module_member_usage/features/demo14/a.ts/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Grid as G } from 'antd';


function A() {
return <G>xx</G>
}

function B() {
return <G>xx</G>
}
10 changes: 10 additions & 0 deletions __test__/module_member_usage/features/demo14/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Grid as G } from 'antd';


function A() {
return <G>xx</G>
}

function B() {
return <G>xx</G>
}
6 changes: 6 additions & 0 deletions __test__/module_member_usage/features/demo15/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// ת�����ʻ���ӳ���ϵ��
export const i18nKeyMaps = {
zhCN: 'zh_CN',
enUS: 'en_US'
}

3 changes: 3 additions & 0 deletions __test__/module_member_usage/features/demo2/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Button } from "antd"

Button;
9 changes: 9 additions & 0 deletions __test__/module_member_usage/features/demo3/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Button } from "antd"

function App() {
return (
<div>
<Button>hello</Button>
</div>
)
}
9 changes: 9 additions & 0 deletions __test__/module_member_usage/features/demo4/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Button } from "antd"

function App() {
return (
<div>
<Button />
</div>
)
}
9 changes: 9 additions & 0 deletions __test__/module_member_usage/features/demo5/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import antd from "antd"

function App() {
return (
<div>
<antd.Button>btn</antd.Button>
</div>
)
}
9 changes: 9 additions & 0 deletions __test__/module_member_usage/features/demo6/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import antd from "antd"

function App() {
return (
<div>
<antd.Button />
</div>
)
}
9 changes: 9 additions & 0 deletions __test__/module_member_usage/features/demo7/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as antd from "antd"

function App() {
return (
<div>
<antd.Button>btn</antd.Button>
</div>
)
}
9 changes: 9 additions & 0 deletions __test__/module_member_usage/features/demo8/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as antd from "antd"

function App() {
return (
<div>
<antd.Button />
</div>
)
}
15 changes: 15 additions & 0 deletions __test__/module_member_usage/features/demo9/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as antd from "antd"
import { deepClone } from "lodash"

function App(props) {

useEffect(() => {
let x = deepClone(props.user)
},[])

return (
<div>
<antd.Button />
</div>
)
}
14 changes: 14 additions & 0 deletions __test__/module_member_usage/index.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import test from "ava";
import { getModuleMemberUsage } from "../../index.js";
import { fileURLToPath } from "node:url";
import { dirname } from "node:path";

// 获取当前文件的路径
const __filename = fileURLToPath(import.meta.url);

test("getUsageOfDangerStrings", (t) => {
const response = getModuleMemberUsage(["antd"], {
cwd: dirname(__filename),
});
t.snapshot(response.sort((x) => x.filePath));
});
Loading

0 comments on commit 25f8d19

Please sign in to comment.