Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 1397f4f

Browse files
authored
Merge pull request #112 from Dschungelabenteuer/fix-windows-paths
fix(no-uninstalled-addons) Support Windows paths
2 parents 8b7f603 + 2d8e6b8 commit 1397f4f

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

lib/rules/no-uninstalled-addons.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { readFileSync } from 'fs'
77
import dedent from 'ts-dedent'
8-
import { resolve, relative } from 'path'
8+
import { resolve, relative, sep } from 'path'
99

1010
import { createStorybookRule } from '../utils/create-storybook-rule'
1111
import { CategoryId } from '../utils/constants'
@@ -187,8 +187,8 @@ export = createStorybookRule({
187187
(elem) => !!result.find((addon) => addon.name === elem.value)
188188
)
189189

190-
const rootDir = process.cwd().split('/').pop()
191-
const packageJsonPath = `${rootDir}/${relative(process.cwd(), packageJsonLocation)}`
190+
const rootDir = process.cwd().split(sep).pop()
191+
const packageJsonPath = `${rootDir}${sep}${relative(process.cwd(), packageJsonLocation)}`
192192

193193
elemsWithErrors.forEach((elem) => {
194194
context.report({

tests/lib/rules/no-uninstalled-addons.test.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { AST_NODE_TYPES } from '@typescript-eslint/utils'
1111

1212
import rule from '../../../lib/rules/no-uninstalled-addons'
1313
import ruleTester from '../../utils/rule-tester'
14+
import { sep } from 'path';
1415

1516
jest.mock('fs', () => ({
1617
...jest.requireActual('fs'),
@@ -137,7 +138,7 @@ ruleTester.run('no-uninstalled-addons', rule, {
137138
type: AST_NODE_TYPES.Literal,
138139
data: {
139140
addonName: '@storybook/not-installed-addon',
140-
packageJsonPath: 'eslint-plugin-storybook/',
141+
packageJsonPath: `eslint-plugin-storybook${sep}`,
141142
},
142143
},
143144
],
@@ -161,7 +162,7 @@ ruleTester.run('no-uninstalled-addons', rule, {
161162
type: AST_NODE_TYPES.Literal,
162163
data: {
163164
addonName: '@storybook/not-installed-addon',
164-
packageJsonPath: 'eslint-plugin-storybook/',
165+
packageJsonPath: `eslint-plugin-storybook${sep}`,
165166
},
166167
},
167168
],
@@ -184,7 +185,7 @@ ruleTester.run('no-uninstalled-addons', rule, {
184185
type: AST_NODE_TYPES.Literal,
185186
data: {
186187
addonName: '@storybook/addon-esentials',
187-
packageJsonPath: 'eslint-plugin-storybook/',
188+
packageJsonPath: `eslint-plugin-storybook${sep}`,
188189
},
189190
},
190191
],
@@ -205,7 +206,7 @@ ruleTester.run('no-uninstalled-addons', rule, {
205206
type: AST_NODE_TYPES.Literal,
206207
data: {
207208
addonName: '@storybook/adon-essentials',
208-
packageJsonPath: 'eslint-plugin-storybook/',
209+
packageJsonPath: `eslint-plugin-storybook${sep}`,
209210
},
210211
},
211212
],
@@ -228,15 +229,15 @@ ruleTester.run('no-uninstalled-addons', rule, {
228229
type: AST_NODE_TYPES.Literal,
229230
data: {
230231
addonName: 'addon-withut-the-prefix',
231-
packageJsonPath: 'eslint-plugin-storybook/',
232+
packageJsonPath: `eslint-plugin-storybook${sep}`,
232233
},
233234
},
234235
{
235236
messageId: 'addonIsNotInstalled', // comes from the rule file
236237
type: AST_NODE_TYPES.Literal,
237238
data: {
238239
addonName: '@storybook/addon-esentials',
239-
packageJsonPath: 'eslint-plugin-storybook/',
240+
packageJsonPath: `eslint-plugin-storybook${sep}`,
240241
},
241242
},
242243
],
@@ -259,15 +260,15 @@ ruleTester.run('no-uninstalled-addons', rule, {
259260
type: AST_NODE_TYPES.Literal,
260261
data: {
261262
addonName: 'addon-withut-the-prefix',
262-
packageJsonPath: 'eslint-plugin-storybook/',
263+
packageJsonPath: `eslint-plugin-storybook${sep}`,
263264
},
264265
},
265266
{
266267
messageId: 'addonIsNotInstalled', // comes from the rule file
267268
type: AST_NODE_TYPES.Literal,
268269
data: {
269270
addonName: '@storybook/addon-esentials',
270-
packageJsonPath: 'eslint-plugin-storybook/',
271+
packageJsonPath: `eslint-plugin-storybook${sep}`,
271272
},
272273
},
273274
],
@@ -289,15 +290,15 @@ ruleTester.run('no-uninstalled-addons', rule, {
289290
type: AST_NODE_TYPES.Literal,
290291
data: {
291292
addonName: 'addon-withut-the-prefix',
292-
packageJsonPath: 'eslint-plugin-storybook/',
293+
packageJsonPath: `eslint-plugin-storybook${sep}`,
293294
},
294295
},
295296
{
296297
messageId: 'addonIsNotInstalled', // comes from the rule file
297298
type: AST_NODE_TYPES.Literal,
298299
data: {
299300
addonName: '@storybook/addon-esentials',
300-
packageJsonPath: 'eslint-plugin-storybook/',
301+
packageJsonPath: `eslint-plugin-storybook${sep}`,
301302
},
302303
},
303304
],

0 commit comments

Comments
 (0)