Skip to content

Commit

Permalink
feat(linter): move common options to target defaults (#20583)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav authored Jan 9, 2024
1 parent 2360918 commit 03257e2
Show file tree
Hide file tree
Showing 35 changed files with 478 additions and 182 deletions.
15 changes: 0 additions & 15 deletions graph/client/src/assets/release-static/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ window.projectGraphResponse = {
'libs/products/product-detail-page/src/**/*.html',
],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
test: {
Expand Down Expand Up @@ -261,7 +260,6 @@ window.projectGraphResponse = {
'libs/shared/product/state/src/**/*.html',
],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
test: {
Expand Down Expand Up @@ -329,7 +327,6 @@ window.projectGraphResponse = {
'libs/shared/product/types/src/**/*.html',
],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
},
Expand Down Expand Up @@ -393,7 +390,6 @@ window.projectGraphResponse = {
'libs/shared/product/data/src/**/*.html',
],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
},
Expand Down Expand Up @@ -498,7 +494,6 @@ window.projectGraphResponse = {
'libs/products/home-page/src/**/*.html',
],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
test: {
Expand Down Expand Up @@ -616,7 +611,6 @@ window.projectGraphResponse = {
'libs/shared/cart/state/src/**/*.html',
],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
test: {
Expand Down Expand Up @@ -702,7 +696,6 @@ window.projectGraphResponse = {
'libs/shared/product/ui/src/**/*.html',
],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
test: {
Expand Down Expand Up @@ -766,7 +759,6 @@ window.projectGraphResponse = {
'libs/shared/e2e-utils/src/**/*.html',
],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
},
Expand Down Expand Up @@ -846,7 +838,6 @@ window.projectGraphResponse = {
'libs/cart/cart-page/src/**/*.html',
],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
test: {
Expand Down Expand Up @@ -987,7 +978,6 @@ window.projectGraphResponse = {
'libs/shared/header/src/**/*.html',
],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
test: {
Expand Down Expand Up @@ -1055,7 +1045,6 @@ window.projectGraphResponse = {
'libs/shared/jsxify/src/**/*.html',
],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
},
Expand Down Expand Up @@ -1154,7 +1143,6 @@ window.projectGraphResponse = {
options: {
lintFilePatterns: ['apps/products-e2e/**/*.{js,ts}'],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
},
Expand Down Expand Up @@ -1226,7 +1214,6 @@ window.projectGraphResponse = {
options: {
lintFilePatterns: ['apps/cart-e2e/**/*.{ts,tsx,js,jsx}'],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
},
Expand Down Expand Up @@ -1432,7 +1419,6 @@ window.projectGraphResponse = {
'apps/products/src/**/*.html',
],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
test: {
Expand Down Expand Up @@ -1637,7 +1623,6 @@ window.projectGraphResponse = {
options: {
lintFilePatterns: ['apps/cart/**/*.{ts,tsx,js,jsx}'],
},
outputs: ['{options.outputFile}'],
inputs: ['default', '{workspaceRoot}/.eslintrc.json'],
},
test: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ describe('addLinting generator', () => {
const project = readProjectConfiguration(tree, appProjectName);
expect(project.targets.lint).toEqual({
executor: '@nx/eslint:lint',
outputs: ['{options.outputFile}'],
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,6 @@ exports[`app --project-name-and-root-format=derived should generate correctly wh
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
"serve": {
"configurations": {
Expand Down Expand Up @@ -336,9 +333,6 @@ exports[`app --project-name-and-root-format=derived should generate correctly wh
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
},
}
Expand Down Expand Up @@ -495,9 +489,6 @@ exports[`app --project-name-and-root-format=derived should generate correctly wh
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
"serve": {
"configurations": {
Expand Down Expand Up @@ -561,9 +552,6 @@ exports[`app --project-name-and-root-format=derived should generate correctly wh
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
},
}
Expand Down Expand Up @@ -1015,9 +1003,6 @@ exports[`app nested should create project configs 1`] = `
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
"serve": {
"configurations": {
Expand Down Expand Up @@ -1081,9 +1066,6 @@ exports[`app nested should create project configs 2`] = `
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
},
}
Expand Down Expand Up @@ -1153,9 +1135,6 @@ exports[`app not nested should create project configs 1`] = `
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
"serve": {
"configurations": {
Expand Down Expand Up @@ -1219,9 +1198,6 @@ exports[`app not nested should create project configs 2`] = `
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,18 +507,12 @@ describe('app', () => {
.toMatchInlineSnapshot(`
{
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
}
`);
expect(readProjectConfiguration(appTree, 'my-app-e2e').targets.lint)
.toMatchInlineSnapshot(`
{
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
}
`);
});
Expand Down
3 changes: 0 additions & 3 deletions packages/angular/src/generators/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1147,9 +1147,6 @@ describe('lib', () => {
.toMatchInlineSnapshot(`
{
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
}
`);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ exports[`workspace move to nx layout should create nx.json 1`] = `
"sharedGlobals": [],
},
"targetDefaults": {
"@nx/eslint:lint": {
"cache": true,
"inputs": [
"default",
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/.eslintignore",
"{workspaceRoot}/eslint.config.js",
],
},
"build": {
"cache": true,
"dependsOn": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ exports[`Cypress Project < v7 nested should update configuration 1`] = `
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
}
`;
Expand Down Expand Up @@ -91,9 +88,6 @@ exports[`Cypress Project < v7 project with directory in its name should update c
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
}
`;
Expand All @@ -111,9 +105,6 @@ exports[`Cypress Project < v7 should update project configuration (baseUrl) 1`]
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
}
`;
Expand All @@ -136,9 +127,6 @@ exports[`Cypress Project < v7 should update project configuration 1`] = `
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
}
`;
Expand All @@ -161,9 +149,6 @@ exports[`Cypress Project < v7 should update target configurations 1`] = `
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
}
`;
Expand Down Expand Up @@ -243,8 +228,5 @@ exports[`Cypress Project > v10 should set right path names in \`tsconfig.e2e.jso
exports[`Cypress Project > v10 should update configuration when eslint is passed 1`] = `
{
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,6 @@ exports[`convertToCypressTen convertCypressProject should infer targets with --a
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
}
`;
Expand Down Expand Up @@ -242,9 +239,6 @@ exports[`convertToCypressTen convertCypressProject should not break when an inva
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}",
],
},
}
`;
Expand Down
5 changes: 5 additions & 0 deletions packages/eslint/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
"version": "17.2.0-beta.0",
"description": "Simplify eslintFilePatterns",
"implementation": "./src/migrations/update-17-2-0/simplify-eslint-patterns"
},
"move-options-to-target-defaults": {
"version": "17.2.9",
"description": "Move executor options to target defaults",
"implementation": "./src/migrations/update-17-2-9/move-options-to-target-defaults"
}
},
"packageJsonUpdates": {
Expand Down
32 changes: 18 additions & 14 deletions packages/eslint/src/generators/init/init.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ describe('@nx/eslint:init', () => {
linter: Linter.EsLint,
});

expect(readJson(tree, 'nx.json').targetDefaults.lint).toEqual({
cache: true,
inputs: [
'default',
'{workspaceRoot}/.eslintrc.json',
'{workspaceRoot}/.eslintignore',
'{workspaceRoot}/eslint.config.js',
],
});
expect(readJson(tree, 'nx.json').targetDefaults['@nx/eslint:lint']).toEqual(
{
cache: true,
inputs: [
'default',
'{workspaceRoot}/.eslintrc.json',
'{workspaceRoot}/.eslintignore',
'{workspaceRoot}/eslint.config.js',
],
}
);
});

it('should not generate the global eslint config if it already exist', async () => {
Expand All @@ -64,7 +66,9 @@ describe('@nx/eslint:init', () => {
await lintInitGenerator(tree, {});

expect(
readJson<NxJsonConfiguration>(tree, 'nx.json').targetDefaults.lint
readJson<NxJsonConfiguration>(tree, 'nx.json').targetDefaults[
'@nx/eslint:lint'
]
).toEqual({
cache: true,
inputs: [
Expand All @@ -87,10 +91,10 @@ describe('@nx/eslint:init', () => {
await lintInitGenerator(tree, {});

expect(
readJson<NxJsonConfiguration>(tree, 'nx.json').targetDefaults.lint
).toEqual({
cache: true,
});
readJson<NxJsonConfiguration>(tree, 'nx.json').targetDefaults[
'@nx/eslint:lint'
]
).toBeUndefined();
expect(readJson<NxJsonConfiguration>(tree, 'nx.json').plugins)
.toMatchInlineSnapshot(`
[
Expand Down
Loading

0 comments on commit 03257e2

Please sign in to comment.