Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deno lint ignores the ignore and exclude options #26308

Open
viktormarinho opened this issue Oct 16, 2024 · 10 comments · May be fixed by #26695
Open

Deno lint ignores the ignore and exclude options #26308

viktormarinho opened this issue Oct 16, 2024 · 10 comments · May be fixed by #26695
Assignees
Labels
bug Something isn't working correctly lint Issues related to deno lint

Comments

@viktormarinho
Copy link
Contributor

Version: Deno 2.0.0

I'm using deno in a workspace that includes a npm package project/packages/ui which is a collection of React components, that use tailwind. In this package, i have a globals.css file that is not valid for the default Deno CSS linter, since i have a setup that uses postcss to process it (for tailwind) etc.

Problem is, i cannot seem to ignore this file in any way. I've tried using --ignore, putting it inside lint: { exclude: [*.css] } inside a deno.json file at the root of the project and at the package, and using a comment at the top of the css file with deno-lint-ignore-file.

Besides all that, deno lint keeps breaking on this file, trying to check it.

@bartlomieju
Copy link
Member

deno lint doesn't try to read CSS files, it's only meant for JS/TS/JSX/TSX files.

Could you please paste an output from your terminal?

@viktormarinho
Copy link
Contributor Author

@bartlomieju Yeah sure, here it is

➜  project git:(6ef580b) deno lint .
error: The module's source code could not be parsed: Expected ';', '}' or <eof> at file:///Users/viktor/repos/project/packages/ui/globals.css:5:13

  @layer base {
              ~

@viktormarinho
Copy link
Contributor Author

Maybe that's happening because the deno.jsonc file at this package exports the globals.css file. When i delete it, this stops happening.

@bartlomieju
Copy link
Member

Can you please paste the contents of deno.jsonc file?

@viktormarinho
Copy link
Contributor Author

Something that could maybe be causing problems here is that, this package includes both a deno.jsonc file and a package.json file. I included the deno.jsonc just because without it deno could not find the types of the package being imported. (I have another issue related to that tho, #26306 )

{
  "name": "@project/ui",
  "exports": {
    "./lib/utils.ts": "./src/lib/utils.ts",
    "./hooks/use-toast.ts": "./src/hooks/use-toast.ts",
    "./components/alert-dialog.tsx": "./src/components/alert-dialog.tsx",
    "./components/avatar.tsx": "./src/components/avatar.tsx",
    "./components/badge.tsx": "./src/components/badge.tsx",
    "./components/button.tsx": "./src/components/button.tsx",
    "./components/command.tsx": "./src/components/command.tsx",
    "./components/dialog.tsx": "./src/components/dialog.tsx",
    "./components/drawer.tsx": "./src/components/drawer.tsx",
    "./components/form.tsx": "./src/components/form.tsx",
    "./components/input.tsx": "./src/components/input.tsx",
    "./components/label.tsx": "./src/components/label.tsx",
    "./components/separator.tsx": "./src/components/separator.tsx",
    "./components/spinner.tsx": "./src/components/spinner.tsx",
    "./components/switch.tsx": "./src/components/switch.tsx",
    "./components/table.tsx": "./src/components/table.tsx",
    "./components/tabs.tsx": "./src/components/tabs.tsx",
    "./components/toast.tsx": "./src/components/toast.tsx",
    "./components/toaster.tsx": "./src/components/toaster.tsx",
    "./components/tooltip.tsx": "./src/components/tooltip.tsx",
    "./postcss.config.mjs": "./postcss.config.mjs",
    "./tailwind.config.ts": "./tailwind.config.ts",
    "./globals.css": "./globals.css"
  }
}

@dsherret
Copy link
Member

dsherret commented Oct 16, 2024

As a workaround, disabling the no-slow-types rule might fix the issue:

// deno.jsonc
{
  "lint": {
    "rules": {
      "exclude": ["no-slow-types"]
    }
  },
  // ...
}

Probably what's happening here is that lint rule is analyzing all the exports of the package.

@viktormarinho
Copy link
Contributor Author

As a workaround, disabling the no-slow-types rule might fix the issue:

// deno.jsonc
{
  "lint": {
    "rules": {
      "exclude": ["no-slow-types"]
    }
  },
  // ...
}

Probably what's happening here is that lint rule is analyzing all the exports of the package.

Still happens with no-slow-types disabled

@littledivy littledivy added bug Something isn't working correctly lint Issues related to deno lint labels Oct 16, 2024
@dmint789
Copy link

This is also a bug with deno fmt. I have a workspace setup where I have this fmt config:

  "fmt": {
    "include": ["*.ts", "*.tsx"],
    "exclude": ["*.d.ts", "./server/*"],
    "lineWidth": 120
  },

This still tries to process JS, CSS and even JSON files. However, when I also exclude the directory which contains those files (my Next JS build directory), it works fine. The include statement just shouldn't work with those files to begin with.

@bartlomieju
Copy link
Member

I was able to reproduce it with these three files:

// deno.json
{
    "name": "@project/ui",
    "exports": {
        "./main.ts": "./main.ts",
        "./globals.css": "./globals.css"
    }
}
// main.ts
// globals.css
body {
    color: "red";
}

Run deno lint:

error: The module's source code could not be parsed: Expected ';', '}' or <eof> at file:///Users/ib/dev/scratch_lint_css/globals.css:1:6

  body {
       ~

Indeed adding lint.exclude doesn't make the problem go away. Removing main.ts from "exports" makes the error go away.

I'll dig into this

@bartlomieju
Copy link
Member

Found one more problem that might be a separate issue. Running deno lint <some file> in the project from the above comment always triggers this error, even though it should only lint one specific file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly lint Issues related to deno lint
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants