Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/busy-sheep-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sv': patch
---

chore(eslint): bump `@eslint/compat` to `^2.0.1`
21 changes: 12 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,28 @@ pnpm dev

For each add-on we have integration tests setup. These install the deps, build the app, run the dev server and then run a few small snippets against the add-on to see if the changes introduced by the add-on are working as expected.

Run all tests:
Tests are split into projects: `cli`, `core`, `addons`, `create`, `migrate`. **Always run tests by project** for faster feedback:

```sh
# from root of project
pnpm test
pnpm test --project migrate # Migrate tests
pnpm test --project core # Core utility tests
pnpm test --project create # Project creation tests
pnpm test --project addons # Add-on tests

pnpm test --project addons eslint # Just eslint add-on tests
pnpm build && pnpm test --project cli # CLI tests
```

Run tests with vitest ui:
Run with vitest ui for interactive debugging:

```sh
# from root of project
pnpm test:ui
pnpm test:ui --project cli
```

We split tests into packages & sub projects.
Run specific tests by specifying a project flag to the package and running the test command. Eg:
Run all tests (slow, typically for CI):

```sh
pnpm test --project cli # core / addons / create / migrate
pnpm test
```

### Debugging
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Read the [SvelteKit documentation](https://svelte.dev/docs/kit) for more details

## Contributing

Please file an issue for discussion before sending a PR for a new add-on. Most new add-ons will likely be recommended to be implemented as community add-ons. This repository will only hold a very limited number of add-ons at the maintainers discretion that address widely held needs, are considered best-in-class, and are widely used in the Svelte community.
Please see the [contributing guide](CONTRIBUTING.md) for more information.

File an issue for discussion before sending a PR for a new add-on. Most new add-ons will likely be recommended to be implemented as community add-ons. This repository will only hold a very limited number of add-ons at the maintainers discretion that address widely held needs, are considered best-in-class, and are widely used in the Svelte community.

## Supporting Svelte

Expand Down
6 changes: 3 additions & 3 deletions packages/sv/lib/addons/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineAddon({
const prettierInstalled = Boolean(dependencyVersion('prettier'));

sv.devDependency('eslint', '^9.39.1');
sv.devDependency('@eslint/compat', '^1.4.0');
sv.devDependency('@eslint/compat', '^2.0.1');
sv.devDependency('eslint-plugin-svelte', '^3.13.1');
sv.devDependency('globals', '^17.1.0');
sv.devDependency('@eslint/js', '^9.39.1');
Expand All @@ -35,7 +35,7 @@ export default defineAddon({
const eslintConfigs: Array<AstTypes.Expression | AstTypes.SpreadElement> = [];
js.imports.addDefault(ast, { from: './svelte.config.js', as: 'svelteConfig' });
const gitIgnorePathStatement = js.common.parseStatement(
"\nconst gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));"
"\nconst gitignorePath = path.resolve(import.meta.dirname, '.gitignore');"
);
js.common.appendStatement(ast, { statement: gitIgnorePathStatement });

Expand Down Expand Up @@ -142,7 +142,7 @@ export default defineAddon({
from: '@eslint/compat',
imports: ['includeIgnoreFile']
});
js.imports.addNamed(ast, { from: 'node:url', imports: ['fileURLToPath'] });
js.imports.addDefault(ast, { from: 'node:path', as: 'path' });

return generateCode();
});
Expand Down
5 changes: 4 additions & 1 deletion packages/sv/lib/cli/add/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ function findWorkspaceRoot(cwd: string): string {
return directory;
}
}
directory = path.dirname(directory);
const parent = path.dirname(directory);
// For test isolation: don't walk up past .test-output directories
if (directory.includes('.test-output') && !parent.includes('.test-output')) break;
directory = parent;
}
// We didn't find a workspace root, so we return the original directory
// it's a standalone project
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
import prettier from 'eslint-config-prettier';
import path from 'node:path';
import { includeIgnoreFile } from '@eslint/compat';
import js from '@eslint/js';
import svelte from 'eslint-plugin-svelte';
import { defineConfig } from 'eslint/config';
import globals from 'globals';
import ts from 'typescript-eslint';
import svelteConfig from './svelte.config.js';

export default [prettier, ...svelte.configs.prettier];
const gitignorePath = path.resolve(import.meta.dirname, '.gitignore');

export default defineConfig(
includeIgnoreFile(gitignorePath),
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs.recommended,
prettier,
...svelte.configs.prettier,
{
languageOptions: { globals: { ...globals.browser, ...globals.node } },
rules: {
// typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
// see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
"no-undef": 'off'
}
},
{
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
languageOptions: {
parserOptions: {
projectService: true,
extraFileExtensions: ['.svelte'],
parser: ts.parser,
svelteConfig
}
}
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"db:studio": "drizzle-kit studio"
},
"devDependencies": {
"@eslint/compat": "^1.4.0",
"@eslint/compat": "^2.0.1",
"@eslint/js": "^9.39.1",
"@inlang/paraglide-js": "^2.6.0",
"@libsql/client": "^0.15.15",
Expand Down
Loading