Skip to content

Conversation

@ieedan
Copy link
Contributor

@ieedan ieedan commented Nov 27, 2024

Fixes #334

Searched the docs and tried the adapters out ended up also adding .wrangler and .netlify

@changeset-bot
Copy link

changeset-bot bot commented Nov 27, 2024

🦋 Changeset detected

Latest commit: 5a5e41c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
sv Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ieedan ieedan changed the title feat: Add .vercel to ignores in eslint addon feat: Add @sveltejs/<adapter> out directories to eslint ignores. Nov 27, 2024
@AdrianGonz97
Copy link
Member

thank you! however I'm not sure if having to manually update the ignores property for every new entry is the best solution (also, TIL that eslint v9 no longer takes the .gitignore file into consideration, which is fun).

perhaps it would be nicer to have the .gitignore automatically included using the @eslint/compat package?

It can be implemented as so:

import { fileURLToPath } from "node:url";
import { includeIgnoreFile } from "@eslint/compat";

const gitignorePath = fileURLToPath(new URL("./.gitignore", import.meta.url));
export default {
 // ...
 includeIgnoreFile(gitignorePath)
}

thoughts? @manuel3108 @benmccann

@manuel3108
Copy link
Member

Yeah, i think that approach would make sense, although we will have basically the same problem in the .gitignore file then. But personally, I don't think this should be implemented in a "hardcoded" way. I would prefer to see this implemented together with #248

@AdrianGonz97
Copy link
Member

AdrianGonz97 commented Nov 27, 2024

I don't think this should be implemented in a "hardcoded" way. I would prefer to see this implemented together with #248

the .gitignore already includes all of the different adapter output dirs anyway (or at least it should, in the case of netlify which needs to be fixed)

@manuel3108
Copy link
Member

the .gitignore already includes all of the different adapter output dirs anyway (or at least it should, in the case of netlify which needs to be fixed)

At this point for me it doesn't look like it's including the vercel output. So that's also missing. But I wouldn't be in favor of adding that globally to the templates, as explained above.

@AdrianGonz97
Copy link
Member

At this point for me it doesn't look like it's including the vercel output. So that's also missing.

here's the currently generated .gitignore:

node_modules

# Output
.output
.vercel
/.svelte-kit
/build

# OS
.DS_Store
Thumbs.db

# Env
.env
.env.*
!.env.example
!.env.test

# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

the only one that's missing is .netlify (and maybe wrangler? i normally use @sveltejs/adapter-cloudflare which outputs into .svelte-kit/cloudflare instead, so idk).

But I wouldn't be in favor of adding that globally to the templates, as explained above.

yea but that would only be helpful for people who are changing adapters via add and not manually. why not just get them all in one go instead? we're already most of the way there anyway since we're only missing 1 or 2 entries.

@manuel3108
Copy link
Member

here's the currently generated .gitignore:

I'm blind, as always!

yea but that would only be helpful for people who are changing adapters via add and not manually. why not just get them all in one go instead? we're already most of the way there anyway since we're only missing 1 or 2 entries.

Good point about the manual stuff, this should be the way.

@ieedan
Copy link
Contributor Author

ieedan commented Nov 27, 2024

I just went through and ran all of the adapters to see what they output since I don't think any of those outputs are actually in the docs for the adapters at least that I could find.

@AdrianGonz97
Copy link
Member

AdrianGonz97 commented Nov 27, 2024

here are the generated dirs in the root:

@sveltejs/adapter-node - /build
@sveltejs/adapter-static - /build
@sveltejs/adapter-cloudflare - /.wrangler 
@sveltejs/adapter-cloudflare-workers /.wrangler
@sveltejs/adapter-netlify - /.netlify
@sveltejs/adapter-vercel - /.vercel

not sure what the .output dir that already exists in the .gitignore is supposed to be for, but we only need to add .wrangler and .netlify to the gitignore.

@ieedan
Copy link
Contributor Author

ieedan commented Nov 27, 2024

Is there a reason there can't just be a exported constant somewhere that has all of these ignores to be used everywhere?

@AdrianGonz97
Copy link
Member

Is there a reason there can't just be a exported constant somewhere that has all of these ignores to be used everywhere?

not exactly sure I follow - who should be exporting these? the individual adapter packages?

@ieedan
Copy link
Contributor Author

ieedan commented Nov 27, 2024

Is there a reason there can't just be a exported constant somewhere that has all of these ignores to be used everywhere?

not exactly sure I follow - who should be exporting these? the individual adapter packages?

I don't think it being a separate package would be practical but it may be nice to have an internal package to use for it? Like a @sveltejs/constants or something idk.

Otherwise you'd have to depend on 10 packages just to figure out what to ignore lol

@AdrianGonz97
Copy link
Member

eh, that would be pretty niche and not particularly helpful when it comes to the gitignore file since there's no way to 'import' those constants into it

anyway, I think we're in agreement that implementing #335 (comment) would be good, so feel free to add it to this PR!

@ieedan
Copy link
Contributor Author

ieedan commented Nov 27, 2024

I meant more it could just be passed around to build whatever files need it.

Either way let me wrap a few things up and I can give it a shot!

@ieedan ieedan changed the title feat: Add @sveltejs/<adapter> out directories to eslint ignores. feat(addons): Respect .gitignore in eslint addon Nov 27, 2024
@ieedan
Copy link
Contributor Author

ieedan commented Nov 27, 2024

This should be it but I cannot seem to get it to build or run tests on my machine I am probably just doing something wrong.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 27, 2024

Open in Stackblitz

npm i https://pkg.pr.new/sveltejs/cli/sv@335
npm i https://pkg.pr.new/sveltejs/cli/svelte-migrate@335

commit: 5a5e41c

Copy link
Member

@manuel3108 manuel3108 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, so much! This seems to be working great!

The only thing im unsure about, is the placement of the includeIgnoreFile call. According to the readme I would understand that this should be placed first in the eslint array, but currently it's placed last. In my local testing though, this didn't make any difference at all.

@ieedan
Copy link
Contributor Author

ieedan commented Nov 29, 2024

Thanks, so much! This seems to be working great!

The only thing im unsure about, is the placement of the includeIgnoreFile call. According to the readme I would understand that this should be placed first in the eslint array, but currently it's placed last. In my local testing though, this didn't make any difference at all.

Yeah if you would rather have it at the beginning I can move it no problem at all!

ieedan and others added 2 commits November 29, 2024 10:59
@ieedan
Copy link
Contributor Author

ieedan commented Nov 29, 2024

Also should I update the template git ignores with the output files mentioned above?

Copy link
Member

@AdrianGonz97 AdrianGonz97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@Rich-Harris
Copy link
Member

preview: https://svelte-dev-git-preview-cli-335-svelte.vercel.app/

this is an automated message

@AdrianGonz97 AdrianGonz97 merged commit 33ecdd5 into sveltejs:main Dec 2, 2024
8 checks passed
@github-actions github-actions bot mentioned this pull request Dec 2, 2024
@ieedan ieedan deleted the eslint-addon-ignores branch December 2, 2024 17:15
@ieedan
Copy link
Contributor Author

ieedan commented Dec 2, 2024

thank you!

I guess the whitespace issue at the top isn't solvable right?

// ...
import ts from 'typescript-eslint';
const gitignorePath = fileURLToPath(new URL("./.gitignore", import.meta.url));

//...

@AdrianGonz97
Copy link
Member

Not at the moment, but we have plans on addressing issues similar to this in the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add .vercel to eslint addon ignores

5 participants