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

Nx 18 Inferred Tasks support #635

Open
Phillip9587 opened this issue Feb 8, 2024 · 3 comments · Fixed by #649
Open

Nx 18 Inferred Tasks support #635

Phillip9587 opened this issue Feb 8, 2024 · 3 comments · Fixed by #649

Comments

@Phillip9587
Copy link
Owner

Support Nx Project Crystal / Inferred Tasks

@Phillip9587
Copy link
Owner Author

v18.0.0-beta.3 provides support for Nx 18 Inferred Tasks

Please test it out and provide feedback.

To add the plugin add the following to your nx.json:

{
    "plugins": [
        {
            "plugin": "nx-stylelint/plugin",
            "options": {
                "targetName": "stylelint",
                "extensions": ["css"]
            }
        }
    ]
}

targetDefaults can be configured e.g. --allow-empty-input:

"targetDefaults": {
    "stylelint": {
        "options": {
            "args": ["--allow-empty-input"]
        }
    }
}

@mateusgpereira
Copy link

I add the plugin to the nx.json file:

{
   "plugin": "nx-stylelint/plugin",
    "options": {
        "targetName": "stylelint",
        "extensions": ["scss"]
    }
 }

I'm also using this on targetDefaults:

"targetDefaults": {
  "stylelint": {
    "inputs": [
      "default",
      "{workspaceRoot}/.stylelintrc(.(json|yml|yaml|js))?"
    ],
    "cache": true,
    "options": {
      "args": [
        "--allow-empty-input"
      ]
    }
  }
}

With this setup I can see the task being inferred in nx console with this description:
Created by nx/core/target-defaults from nx.json
but only for the libraries that have their own .stylelintrc file.
It would be nice to have this task inferred independently of the lib having or not its own configuration file and using the rules defined at the workspaceRoot level.

Great job with this plugin guys ^^

@Phillip9587
Copy link
Owner Author

@mateusgpereira Thanks for trying out the plugin.

I'm also using this on targetDefaults:

"targetDefaults": {
  "stylelint": {
    "inputs": [
      "default",
      "{workspaceRoot}/.stylelintrc(.(json|yml|yaml|js))?"
    ],
    "cache": true,
    "options": {
      "args": [
        "--allow-empty-input"
      ]
    }
  }
}

You can remove the inputs here. The Inputs are infered by the plugin.

With this setup I can see the task being inferred in nx console with this description: Created by nx/core/target-defaults from nx.json but only for the libraries that have their own .stylelintrc file. It would be nice to have this task inferred independently of the lib having or not its own configuration file and using the rules defined at the workspaceRoot level.

First, remove the stylelint targets from your project.json files. It looks like there is a stylelint target with the nx-stylelint:lint executor left. The stylelint target has to be infered from nx-stylelint/plugin.

The libraries need a .stylelintrc file to identify them as projects that need Stylelint setup. However, you can add a simple .stylelintrc.json to your project root that extends the workspace root .stylelintrc file:

{
    "extends": "../path/to/workspaceroot/.stylelintrc.json"
}

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 a pull request may close this issue.

2 participants