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

Uplift internal linting #1370

Merged
merged 17 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/five-dancers-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'skuba': minor
---

lint: Overhaul internal linting system

Previously, internal lint rules would not fail a `skuba lint` check but would silently make changes to your working tree. These changes may have never been committed and may have caused subsequent noise when running `skuba format` or `skuba lint`.

Now, internal linting is now promoted to a top-level tool alongside ESLint, Prettier, and tsc. Rules will report whether changes need to be made, and changes will only be applied in `format` or autofix modes (in CI). As a consequence, `skuba lint` may fail upon upgrading to this version if your project has internal lint violations that have been left unaddressed up to this point.

You can configure `skuba lint` to automatically push autofixes; this eases adoption of linting rule changes and automatically resolves issues arising from a forgotten `skuba format`. You'll need to configure your CI environment to support this feature. See our [GitHub autofixes](https://seek-oss.github.io/skuba/docs/deep-dives/github.html#github-autofixes) documentation to learn more.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ node_modules*/
# end managed by skuba

/integration/base/
/integration/format/
/template/
1 change: 1 addition & 0 deletions integration/base/patch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM gcr.io/distroless/nodejs:18 AS runtime
7 changes: 7 additions & 0 deletions integration/base/patch/a/a/a.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Imports in order
import fs from 'fs';
import path from 'path';

export const main = async () => {
await fs.promises.access(path.join('.', 'a.ts'));
};
3 changes: 3 additions & 0 deletions integration/base/patch/b.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Title

No trailing space
3 changes: 3 additions & 0 deletions integration/base/patch/c.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"key": "value"
}
2 changes: 2 additions & 0 deletions integration/base/patch/d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line no-console
console.log(process.argv);
13 changes: 13 additions & 0 deletions integration/base/patch/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"private": true,
"license": "UNLICENSED",
"sideEffects": false,
"dependencies": {},
"devDependencies": {},
"skuba": {
"entryPoint": null,
"template": null,
"type": "application",
"version": "0.0.1"
}
}
9 changes: 9 additions & 0 deletions integration/base/patch/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"incremental": true,
"moduleResolution": "node",
"outDir": "lib",
"skipLibCheck": true
},
"extends": "tsconfig-seek"
}
56 changes: 52 additions & 4 deletions src/cli/__snapshots__/format.int.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@

exports[`fixable 1`] = `
"
skuba lints
Refreshed .eslintignore. refresh-ignore-files
Refreshed .gitignore. refresh-ignore-files
Refreshed .prettierignore. refresh-ignore-files
Updating skuba...

Patch 7.3.1 applied.
Patch skipped: Add empty exports to Jest files for compliance with TypeScript isolated modules

Patch skipped: Update Renovate config to support private SEEK packages - owner does not map to a SEEK preset

Patch skipped: Upgrade Node.js Distroless Docker image to -debian11 variant - no Dockerfile found

Patch skipped: Add keepAliveTimeout to server listener - no listener file found

skuba update complete.

Processed skuba lints in <random>s.

ESLint
Processed 4 files in <random>s.

Expand Down Expand Up @@ -57,12 +69,24 @@ d.js

exports[`ok --debug 1`] = `
"
skuba lints
Refreshed .eslintignore. refresh-ignore-files
Refreshed .gitignore. refresh-ignore-files
Refreshed .prettierignore. refresh-ignore-files
Updating skuba...

Patch 7.3.1 applied.
Patch skipped: Add empty exports to Jest files for compliance with TypeScript isolated modules

Patch skipped: Update Renovate config to support private SEEK packages - owner does not map to a SEEK preset

Patch skipped: Upgrade Node.js Distroless Docker image to -debian11 variant - no Dockerfile found

Patch skipped: Add keepAliveTimeout to server listener - no listener file found

skuba update complete.

Processed skuba lints in <random>s.

ESLint
Initialising ESLint...
Processing files...
Expand Down Expand Up @@ -105,12 +129,24 @@ exports[`ok --debug 2`] = `

exports[`ok 1`] = `
"
skuba lints
Refreshed .eslintignore. refresh-ignore-files
Refreshed .gitignore. refresh-ignore-files
Refreshed .prettierignore. refresh-ignore-files
Updating skuba...

Patch 7.3.1 applied.
Patch skipped: Add empty exports to Jest files for compliance with TypeScript isolated modules

Patch skipped: Update Renovate config to support private SEEK packages - owner does not map to a SEEK preset

Patch skipped: Upgrade Node.js Distroless Docker image to -debian11 variant - no Dockerfile found

Patch skipped: Add keepAliveTimeout to server listener - no listener file found

skuba update complete.

Processed skuba lints in <random>s.

ESLint
Processed 2 files in <random>s.

Expand All @@ -126,12 +162,24 @@ exports[`ok 2`] = `

exports[`unfixable 1`] = `
"
skuba lints
Refreshed .eslintignore. refresh-ignore-files
Refreshed .gitignore. refresh-ignore-files
Refreshed .prettierignore. refresh-ignore-files
Updating skuba...

Patch 7.3.1 applied.
Patch skipped: Add empty exports to Jest files for compliance with TypeScript isolated modules

Patch skipped: Update Renovate config to support private SEEK packages - owner does not map to a SEEK preset

Patch skipped: Upgrade Node.js Distroless Docker image to -debian11 variant - no Dockerfile found

Patch skipped: Add keepAliveTimeout to server listener - no listener file found

skuba update complete.

Processed skuba lints in <random>s.

ESLint
Processed 2 files in <random>s.

Expand Down
76 changes: 41 additions & 35 deletions src/cli/__snapshots__/lint.int.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

exports[`fixable 1`] = `
"
Updating skuba...

Patch 7.3.1 applied.

skuba update complete.

ESLint │ Processed 4 files in <random>s.
ESLint │
<random>/a/a/a.mjs
Expand All @@ -23,25 +17,24 @@ ESLint │
3 errors and 0 warnings potentially fixable with the \`--fix\` option.

Prettier │ Processed 8 files in <random>s.
Prettier │ Flagged 3 files:
Prettier │ Flagged 4 files:
Prettier │ b.md
Prettier │ c.json
Prettier │ d.js
Prettier │ package.json
tsc │ TSFILE: <random>/lib/tsconfig.tsbuildinfo
tsc │ tsc --noEmit exited with code 0

skuba │ Processed skuba lints in <random>s.
ESLint, Prettier found issues that require triage.

Try running yarn skuba format to fix them.
"
`;

exports[`fixable 2`] = `
[
"
Options: {
context: 'skuba-lint-external',
scopeContextToStep: true,
style: 'error'
}
Options: { context: 'skuba-lint', scopeContextToStep: true, style: 'error' }

\`skuba lint\` found issues that require triage:

Expand All @@ -67,19 +60,44 @@ Options: {
b.md
c.json
d.js
package.json
\`\`\`
",
]
`;

exports[`ok --debug 1`] = `
exports[`needs patches 1`] = `
"
Updating skuba...
ESLint │ Processed 2 files in <random>s.
Prettier │ Processed 6 files in <random>s.
tsc │ TSFILE: <random>/lib/tsconfig.tsbuildinfo
tsc │ tsc --noEmit exited with code 0
skuba │ skuba has patches to apply. Run yarn skuba format to run them. skuba-patches
skuba │ Processed skuba lints in <random>s.
skuba found issues that require triage.

Try running yarn skuba format to fix them.
"
`;

exports[`needs patches 2`] = `
[
"
Options: { context: 'skuba-lint', scopeContextToStep: true, style: 'error' }

Patch 7.3.1 applied.
\`skuba lint\` found issues that require triage:

skuba update complete.
**skuba**

\`\`\`term
<random>/package.json skuba has patches to apply. Run yarn skuba format to run them.
\`\`\`
",
]
`;

exports[`ok --debug 1`] = `
"
ESLint │ Initialising ESLint...
ESLint │ Processing files...
ESLint │ Processed 2 files in <random>s.
Expand Down Expand Up @@ -139,36 +157,26 @@ tsc │ printTime time: <random>s
tsc │ Emit time: <random>s
tsc │ Total time: <random>s
tsc │ tsc --extendedDiagnostics --noEmit exited with code 0
skuba │ Processed skuba lints in <random>s.
"
`;

exports[`ok --debug 2`] = `[]`;

exports[`ok 1`] = `
"
Updating skuba...

Patch 7.3.1 applied.

skuba update complete.

ESLint │ Processed 2 files in <random>s.
Prettier │ Processed 6 files in <random>s.
tsc │ TSFILE: <random>/lib/tsconfig.tsbuildinfo
tsc │ tsc --noEmit exited with code 0
skuba │ Processed skuba lints in <random>s.
"
`;

exports[`ok 2`] = `[]`;

exports[`unfixable 1`] = `
"
Updating skuba...

Patch 7.3.1 applied.

skuba update complete.

ESLint │ Processed 2 files in <random>s.
ESLint │
<random>/a/a/a.ts
Expand All @@ -191,19 +199,17 @@ Prettier │ a/a/a.ts
tsc │ d.js(1,1): error TS1128: Declaration or statement expected.
tsc │ TSFILE: <random>/lib/tsconfig.tsbuildinfo
tsc │ tsc --noEmit exited with code 2

skuba │ Processed skuba lints in <random>s.
ESLint, Prettier, tsc found issues that require triage.

Try running yarn skuba format to fix them.
"
`;

exports[`unfixable 2`] = `
[
"
Options: {
context: 'skuba-lint-external',
scopeContextToStep: true,
style: 'error'
}
Options: { context: 'skuba-lint', scopeContextToStep: true, style: 'error' }

\`skuba lint\` found issues that require triage:

Expand Down
Loading
Loading