Skip to content

Commit

Permalink
setup(all): refactor nx lint targets to accept --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
NexZhu committed Dec 15, 2023
1 parent 186e713 commit cf8b495
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 99 deletions.
21 changes: 3 additions & 18 deletions apps/desktop/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@
"build": {
"executor": "nx:run-commands",
"options": {
"cwd": "./apps/desktop",
"command": "mkdir -p dist && echo 'app' > dist/index.js"
}
},
"eslint": {
"options": {
"command": "mkdir -p dist && echo 'app' > dist/index.js",
"cwd": "./apps/desktop"
}
},
"eslint:fix": {
"lint": {},
"eslint": {
"options": {
"cwd": "./apps/desktop"
}
Expand All @@ -25,17 +21,6 @@
"cwd": "./apps/desktop"
}
},
"stylelint:fix": {
"options": {
"cwd": "./apps/desktop"
}
},
"lint": {
"executor": "nx:noop"
},
"lint:fix": {
"executor": "nx:noop"
},
"container": {
"executor": "@nx-tools/nx-container:build",
"options": {
Expand Down
23 changes: 5 additions & 18 deletions apps/web/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
"build": {
"executor": "nx:run-commands",
"options": {
"cwd": "./apps/web",
"command": "mkdir -p dist && echo 'app' > dist/index.js"
}
},
"eslint": {
"options": {
"command": "mkdir -p dist && echo 'app' > dist/index.js",
"cwd": "./apps/web"
}
},
"eslint:fix": {

"lint": {},
"eslint": {
"options": {
"cwd": "./apps/web"
}
Expand All @@ -25,17 +22,7 @@
"cwd": "./apps/web"
}
},
"stylelint:fix": {
"options": {
"cwd": "./apps/web"
}
},
"lint": {
"executor": "nx:noop"
},
"lint:fix": {
"executor": "nx:noop"
},

"container": {
"executor": "@nx-tools/nx-container:build",
"options": {
Expand Down
4 changes: 0 additions & 4 deletions k8s/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"name": "@fgweb/k8s",
"main": "src/index.ts",
"scripts": {
"lint": "biome check .",
"lint:fix": "biome check --apply ."
},
"dependencies": {
"@pulumi/kubernetes": "^4.5.4",
"@pulumi/kubernetesx": "^0.1.6",
Expand Down
13 changes: 13 additions & 0 deletions k8s/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "k8s",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "k8s/src",
"targets": {
"lint": {
"options": {
"command": "[ {args.fix} = 'true' ] && biome check . || biome check --apply .",
"cwd": "k8s"
}
}
}
}
46 changes: 18 additions & 28 deletions nx.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ const config = {
targetDefaults: {
build: {
dependsOn: ['^build'],
cache: true,
inputs: ['default'],
// outputs,
cache: true,
},

test: {
dependsOn: ['build'],
cache: true,
inputs: [
'{projectRoot}/src/**/*.js',
'{projectRoot}/src/**/*.jsx',
Expand All @@ -42,53 +43,42 @@ const config = {
'{projectRoot}/test/**/*.tsx',
'{projectRoot}/src/**/*.vue',
],
cache: true,
},

dev: {
cache: false,
},

eslint: {
lint: {
dependsOn: [
// To pass "--fix"
{ project: 'self', target: 'eslint', params: 'forward' },
{ project: 'self', target: 'stylelint', params: 'forward' },
],
cache: true,
inputs: [...inputsIgnore],
// Can't use "nx:noop" for it doesn't allow passing args
// executor: 'nx:noop',
executor: 'nx:run-commands',
options: {
command: 'echo eslint ',
command: 'echo lint done, args:',
},
},

'eslint:fix': {
eslint: {
cache: true,
executor: 'nx:run-commands',
options: {
command: 'echo eslint:fix',
command: 'FIX={args.fix}; echo eslint --fix=${FIX:-false}',
},
},

stylelint: {
cache: true,
executor: 'nx:run-commands',
options: {
command: 'echo stylelint',
},
},

'stylelint:fix': {
executor: 'nx:run-commands',
options: {
command: 'echo stylelint:fix',
command: 'FIX={args.fix}; echo stylelint --fix=${FIX:-false}',
},
},

lint: {
dependsOn: ['eslint', 'stylelint'],
inputs: [...inputsIgnore],
cache: true,
},

'lint:fix': {
dependsOn: ['eslint:fix', 'stylelint:fix'],
inputs: [...inputsIgnore],
cache: true,
},

container: {
dependsOn: ['build'],
cache: true,
Expand Down
56 changes: 25 additions & 31 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
"dependsOn": [
"^build"
],
"cache": true,
"inputs": [
"default"
],
"cache": true
]
},
"test": {
"dependsOn": [
"build"
],
"cache": true,
"inputs": [
"{projectRoot}/src/**/*.js",
"{projectRoot}/src/**/*.jsx",
Expand All @@ -38,52 +39,45 @@
"{projectRoot}/test/**/*.ts",
"{projectRoot}/test/**/*.tsx",
"{projectRoot}/src/**/*.vue"
],
"cache": true
]
},
"dev": {
"cache": false
},
"eslint": {
"lint": {
"dependsOn": [
{
"project": "self",
"target": "eslint",
"params": "forward"
},
{
"project": "self",
"target": "stylelint",
"params": "forward"
}
],
"cache": true,
"inputs": [],
"executor": "nx:run-commands",
"options": {
"command": "echo eslint "
"command": "echo lint done, args:"
}
},
"eslint:fix": {
"eslint": {
"cache": true,
"executor": "nx:run-commands",
"options": {
"command": "echo eslint:fix"
"command": "FIX={args.fix}; echo eslint --fix=${FIX:-false}"
}
},
"stylelint": {
"cache": true,
"executor": "nx:run-commands",
"options": {
"command": "echo stylelint"
}
},
"stylelint:fix": {
"executor": "nx:run-commands",
"options": {
"command": "echo stylelint:fix"
"command": "FIX={args.fix}; echo stylelint --fix=${FIX:-false}"
}
},
"lint": {
"dependsOn": [
"eslint",
"stylelint"
],
"inputs": [],
"cache": true
},
"lint:fix": {
"dependsOn": [
"eslint:fix",
"stylelint:fix"
],
"inputs": [],
"cache": true
},
"container": {
"dependsOn": [
"build"
Expand Down

0 comments on commit cf8b495

Please sign in to comment.