Skip to content

Commit

Permalink
feat: update to Nx 16
Browse files Browse the repository at this point in the history
nx-stylelint 16 requires Nx 16

BREAKING CHANGE: Support for Nx v15 has been removed
  • Loading branch information
Phillip9587 committed Oct 8, 2023
1 parent c927500 commit f9b6887
Show file tree
Hide file tree
Showing 37 changed files with 3,609 additions and 6,114 deletions.
8 changes: 4 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
Expand All @@ -23,12 +23,12 @@
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

**Nx plugin to use [Stylelint](https://stylelint.io) in your Nx workspace.**

[![Nx peer dependency version](https://img.shields.io/npm/dependency-version/nx-stylelint/@nrwl/devkit?label=Nx&logo=nx&style=flat-square)](https://nx.dev)
[![Nx peer dependency version](https://img.shields.io/npm/dependency-version/nx-stylelint/@nx/devkit?label=Nx&logo=nx&style=flat-square)](https://nx.dev)
[![Stylelint peer dependency version](https://img.shields.io/npm/dependency-version/nx-stylelint/peer/stylelint?label=Stylelint&logo=stylelint&style=flat-square)](https://stylelint.io)
[![CI](https://img.shields.io/github/actions/workflow/status/Phillip9587/nx-stylelint/ci.yml?branch=main&label=CI&style=flat-square&logo=github)](https://github.com/Phillip9587/nx-stylelint/actions/workflows/ci.yml)
[![LICENSE](https://img.shields.io/github/license/phillip9587/nx-stylelint?style=flat-square)](https://github.com/phillip9587/nx-stylelint/blob/main/LICENSE)
Expand Down Expand Up @@ -342,6 +342,7 @@ Or the name of your installed formatter package e.g. [`stylelint-formatter-prett

| Nx Stylelint Version | Nx Version | Stylelint Version |
| -------------------- | ---------- | ----------------- |
| `^16.0.0` | `>=16.0.0` | `^15.0.0` |
| `^15.0.0` | `>=15.0.0` | `^15.0.0` |
| `^14.0.0` | `>=14.0.0` | `^14.10.0` |
| `^13.0.0` | `>=12.0.0` | `^14.0.0` |
Expand Down
11 changes: 6 additions & 5 deletions e2e/nx-stylelint-e2e/project.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"name": "nx-stylelint-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "e2e/nx-stylelint-e2e/src",
"targets": {
"e2e": {
"executor": "@nrwl/nx-plugin:e2e",
"executor": "@nx/jest:jest",
"options": {
"target": "nx-stylelint:build",
"jestConfig": "e2e/nx-stylelint-e2e/jest.config.ts"
}
"jestConfig": "e2e/nx-stylelint-e2e/jest.config.ts",
"runInBand": true
},
"dependsOn": ["nx-stylelint:build"]
}
},
"implicitDependencies": ["nx-stylelint"]
Expand Down
40 changes: 20 additions & 20 deletions e2e/nx-stylelint-e2e/tests/nx-stylelint.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { checkFilesExist, ensureNxProject, readJson, runNxCommandAsync, cleanup, uniq } from '@nrwl/nx-plugin/testing';
import { NxJsonConfiguration, ProjectConfiguration, TargetConfiguration } from '@nrwl/devkit';
import { checkFilesExist, ensureNxProject, readJson, runNxCommandAsync, cleanup, uniq } from '@nx/plugin/testing';
import { NxJsonConfiguration, ProjectConfiguration, TargetConfiguration } from '@nx/devkit';
import type { Config } from 'stylelint';

describe('nx-stylelint-e2e', () => {
Expand Down Expand Up @@ -50,11 +50,11 @@ describe('nx-stylelint-e2e', () => {
describe('nx-stylelint:configuration', () => {
it('should add a stylelint configuration to a project', async () => {
const projName = uniq('nx-stylelint');
await runNxCommandAsync(`generate @nrwl/js:library --name ${projName}`);
await runNxCommandAsync(`generate @nx/js:library --name ${projName}`);
await runNxCommandAsync(`generate nx-stylelint:configuration --project ${projName}`);

expect(() =>
checkFilesExist('.stylelintrc.json', 'package.json', 'nx.json', `libs/${projName}/.stylelintrc.json`)
checkFilesExist('.stylelintrc.json', 'package.json', 'nx.json', `${projName}/.stylelintrc.json`)
).not.toThrow();

const packageJson = readJson('package.json');
Expand All @@ -76,9 +76,9 @@ describe('nx-stylelint-e2e', () => {
rules: {},
});

const projectConfig = readJson<Config>(`libs/${projName}/.stylelintrc.json`);
const projectConfig = readJson<Config>(`${projName}/.stylelintrc.json`);
expect(projectConfig).toStrictEqual<Config>({
extends: ['../../.stylelintrc.json'],
extends: ['../.stylelintrc.json'],
ignoreFiles: ['!**/*'],
overrides: [
{
Expand All @@ -97,12 +97,12 @@ describe('nx-stylelint-e2e', () => {
inputs: ['default', '{workspaceRoot}/.stylelintrc(.(json|yml|yaml|js))?'],
});

const projectJson = readJson<ProjectConfiguration>(`libs/${projName}/project.json`);
const projectJson = readJson<ProjectConfiguration>(`${projName}/project.json`);

expect(projectJson.targets.stylelint).toStrictEqual<TargetConfiguration>({
executor: 'nx-stylelint:lint',
options: {
lintFilePatterns: [`libs/${projName}/**/*.css`],
lintFilePatterns: [`${projName}/**/*.css`],
},
outputs: ['{options.outputFile}'],
});
Expand All @@ -111,11 +111,11 @@ describe('nx-stylelint-e2e', () => {
describe('--formatter', () => {
it('should add a stylelint configuration to a project and set the specified formatter', async () => {
const projName = uniq('nx-stylelint');
await runNxCommandAsync(`generate @nrwl/js:library --name ${projName}`);
await runNxCommandAsync(`generate @nx/js:library --name ${projName}`);
await runNxCommandAsync(`generate nx-stylelint:configuration --project ${projName} --formatter json`);

expect(() =>
checkFilesExist('.stylelintrc.json', 'package.json', 'nx.json', `libs/${projName}/.stylelintrc.json`)
checkFilesExist('.stylelintrc.json', 'package.json', 'nx.json', `${projName}/.stylelintrc.json`)
).not.toThrow();

const packageJson = readJson('package.json');
Expand All @@ -138,9 +138,9 @@ describe('nx-stylelint-e2e', () => {
rules: {},
});

const projectConfig = readJson<Config>(`libs/${projName}/.stylelintrc.json`);
const projectConfig = readJson<Config>(`${projName}/.stylelintrc.json`);
expect(projectConfig).toStrictEqual<Config>({
extends: ['../../.stylelintrc.json'],
extends: ['../.stylelintrc.json'],
ignoreFiles: ['!**/*'],
overrides: [
{
Expand All @@ -159,12 +159,12 @@ describe('nx-stylelint-e2e', () => {
inputs: ['default', '{workspaceRoot}/.stylelintrc(.(json|yml|yaml|js))?'],
});

const projectJson = readJson<ProjectConfiguration>(`libs/${projName}/project.json`);
const projectJson = readJson<ProjectConfiguration>(`${projName}/project.json`);

expect(projectJson.targets.stylelint).toStrictEqual<TargetConfiguration>({
executor: 'nx-stylelint:lint',
options: {
lintFilePatterns: [`libs/${projName}/**/*.css`],
lintFilePatterns: [`${projName}/**/*.css`],
formatter: 'json',
},
outputs: ['{options.outputFile}'],
Expand All @@ -176,12 +176,12 @@ describe('nx-stylelint-e2e', () => {
describe('nx-stylelint:scss', () => {
it('should add scss support to a target and configuration', async () => {
const projName = uniq('nx-stylelint');
await runNxCommandAsync(`generate @nrwl/js:library --name ${projName}`);
await runNxCommandAsync(`generate @nx/js:library --name ${projName}`);
await runNxCommandAsync(`generate nx-stylelint:configuration --project ${projName}`);
await runNxCommandAsync(`generate nx-stylelint:scss --project ${projName}`);

expect(() =>
checkFilesExist('.stylelintrc.json', 'package.json', 'nx.json', `libs/${projName}/.stylelintrc.json`)
checkFilesExist('.stylelintrc.json', 'package.json', 'nx.json', `${projName}/.stylelintrc.json`)
).not.toThrow();

const packageJson = readJson('package.json');
Expand Down Expand Up @@ -209,9 +209,9 @@ describe('nx-stylelint-e2e', () => {
rules: {},
});

const projectConfig = readJson<Config>(`libs/${projName}/.stylelintrc.json`);
const projectConfig = readJson<Config>(`${projName}/.stylelintrc.json`);
expect(projectConfig).toStrictEqual<Config>({
extends: ['../../.stylelintrc.json'],
extends: ['../.stylelintrc.json'],
ignoreFiles: ['!**/*'],
overrides: [
{
Expand All @@ -234,12 +234,12 @@ describe('nx-stylelint-e2e', () => {
inputs: ['default', '{workspaceRoot}/.stylelintrc(.(json|yml|yaml|js))?'],
});

const projectJson: ProjectConfiguration = readJson(`libs/${projName}/project.json`);
const projectJson: ProjectConfiguration = readJson(`${projName}/project.json`);

expect(projectJson.targets.stylelint).toStrictEqual<TargetConfiguration>({
executor: 'nx-stylelint:lint',
options: {
lintFilePatterns: [`libs/${projName}/**/*.css`, `libs/${projName}/**/*.scss`],
lintFilePatterns: [`${projName}/**/*.css`, `${projName}/**/*.scss`],
},
outputs: ['{options.outputFile}'],
});
Expand Down
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getJestProjects } from '@nrwl/jest';
import { getJestProjects } from '@nx/jest';
import type { Config } from '@jest/types';

const config: Config.InitialOptions = {
Expand Down
2 changes: 1 addition & 1 deletion jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const nxPreset = require('@nrwl/jest/preset').default;
const nxPreset = require('@nx/jest/preset').default;

module.exports = { ...nxPreset };
5 changes: 3 additions & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"defaultProject": "nx-stylelint",
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/nx-cloud",
"runner": "nx-cloud",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"],
"runtimeCacheInputs": ["node --version"],
Expand Down Expand Up @@ -42,7 +42,8 @@
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/.eslintrc.json"
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/src/test-setup.[jt]s"
]
}
}
Loading

0 comments on commit f9b6887

Please sign in to comment.