denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
96.4k stars 5.33k forks source link

Deno lint ignores the `ignore` and `exclude` options #26308

Open viktormarinho opened 2 days ago

viktormarinho commented 2 days ago

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 commented 2 days ago

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 commented 2 days ago

@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 commented 2 days ago

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 commented 2 days ago

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

viktormarinho commented 2 days ago

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 commented 2 days ago

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 commented 2 days ago

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