Skip to content

Commit

Permalink
Fix S4328: Consider package.json name attribute as a dependency (#4393
Browse files Browse the repository at this point in the history
)
  • Loading branch information
vdiez authored Nov 16, 2023
1 parent d77645d commit 131cd48
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 106 deletions.

This file was deleted.

91 changes: 1 addition & 90 deletions its/ruling/src/test/expected/jsts/vuetify/typescript-S4328.json
Original file line number Diff line number Diff line change
Expand Up @@ -452,57 +452,12 @@
11,
15
],
"vuetify:packages/vuetify/src/components/VCalendar/VCalendar.ts": [
40
],
"vuetify:packages/vuetify/src/components/VCalendar/VCalendarCategory.ts": [
15
],
"vuetify:packages/vuetify/src/components/VCalendar/VCalendarDaily.ts": [
21
],
"vuetify:packages/vuetify/src/components/VCalendar/VCalendarMonthly.ts": [
12
],
"vuetify:packages/vuetify/src/components/VCalendar/VCalendarWeekly.ts": [
25
],
"vuetify:packages/vuetify/src/components/VCalendar/mixins/calendar-base.ts": [
27
],
"vuetify:packages/vuetify/src/components/VCalendar/mixins/calendar-with-events.ts": [
31
],
"vuetify:packages/vuetify/src/components/VCalendar/mixins/calendar-with-intervals.ts": [
20
],
"vuetify:packages/vuetify/src/components/VCalendar/mixins/times.ts": [
11
],
"vuetify:packages/vuetify/src/components/VCalendar/modes/column.ts": [
4
],
"vuetify:packages/vuetify/src/components/VCalendar/modes/common.ts": [
4
],
"vuetify:packages/vuetify/src/components/VCalendar/modes/index.ts": [
4
],
"vuetify:packages/vuetify/src/components/VCalendar/modes/stack.ts": [
4
],
"vuetify:packages/vuetify/src/components/VCalendar/util/events.ts": [
11
],
"vuetify:packages/vuetify/src/components/VCalendar/util/parser.ts": [
4
],
"vuetify:packages/vuetify/src/components/VCalendar/util/props.ts": [
7
],
"vuetify:packages/vuetify/src/components/VCalendar/util/timestamp.ts": [
4
],
"vuetify:packages/vuetify/src/components/VCard/VCard.tsx": [
10,
11,
Expand Down Expand Up @@ -679,42 +634,9 @@
8,
12
],
"vuetify:packages/vuetify/src/components/VData/VData.ts": [
9
],
"vuetify:packages/vuetify/src/components/VDataIterator/VDataFooter.ts": [
13
],
"vuetify:packages/vuetify/src/components/VDataIterator/VDataIterator.ts": [
20
],
"vuetify:packages/vuetify/src/components/VDatePicker/VDatePicker.ts": [
34
],
"vuetify:packages/vuetify/src/components/VDatePicker/VDatePickerDateTable.ts": [
15
],
"vuetify:packages/vuetify/src/components/VDatePicker/VDatePickerHeader.ts": [
21
],
"vuetify:packages/vuetify/src/components/VDatePicker/VDatePickerMonthTable.ts": [
13
],
"vuetify:packages/vuetify/src/components/VDatePicker/VDatePickerYears.ts": [
20
],
"vuetify:packages/vuetify/src/components/VDatePicker/mixins/date-picker-table.ts": [
27
],
"vuetify:packages/vuetify/src/components/VDatePicker/util/__tests__/sanitizeDateString.spec.ts": [
1
],
"vuetify:packages/vuetify/src/components/VDatePicker/util/createNativeLocaleFormatter.ts": [
5
],
"vuetify:packages/vuetify/src/components/VDatePicker/util/isDateAllowed.ts": [
4
],
"vuetify:packages/vuetify/src/components/VDefaultsProvider/VDefaultsProvider.tsx": [
2,
6,
Expand Down Expand Up @@ -1519,12 +1441,6 @@
18,
19
],
"vuetify:packages/vuetify/src/components/VTreeview/VTreeview.ts": [
10
],
"vuetify:packages/vuetify/src/components/VTreeview/util/filterTreeItems.ts": [
5
],
"vuetify:packages/vuetify/src/components/VValidation/VValidation.tsx": [
2,
5
Expand Down Expand Up @@ -1991,12 +1907,7 @@
7
],
"vuetify:packages/vuetify/src/services/goto/__tests__/goto.spec.ts": [
6,
16
],
"vuetify:packages/vuetify/src/services/goto/index.ts": [
15,
17
6
],
"vuetify:packages/vuetify/src/util/__tests__/colorUtils.spec.ts": [
1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "local-dependency",
"dependencies": {
"top-dependency": "latest"
}
Expand Down
23 changes: 12 additions & 11 deletions packages/jsts/src/rules/S4328/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,18 @@ function getDependencies(fileName: string) {

function getDependenciesFromPackageJson(content: PackageJson) {
const result = new Set<string>();
try {
if (content.dependencies !== undefined) {
addDependencies(result, content.dependencies);
}
if (content.devDependencies !== undefined) {
addDependencies(result, content.devDependencies);
}
if (content.peerDependencies !== undefined) {
addDependencies(result, content.peerDependencies);
}
} catch {}
if (content.name) {
addDependencies(result, { [content.name]: '*' });
}
if (content.dependencies !== undefined) {
addDependencies(result, content.dependencies);
}
if (content.devDependencies !== undefined) {
addDependencies(result, content.devDependencies);
}
if (content.peerDependencies !== undefined) {
addDependencies(result, content.peerDependencies);
}
return result;
}

Expand Down
1 change: 1 addition & 0 deletions packages/jsts/src/rules/S4328/unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ ruleTesterNestedPackage.run('all levels of package.json should be considered', r
code: `
import { f as f1 } from 'top-dependency';
import { f as f2 } from 'nested-dependency';
import { f as f2 } from 'local-dependency';
`,
filename: filenameNestedPackage,
},
Expand Down

0 comments on commit 131cd48

Please sign in to comment.