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

TS Check, Lint, and Format new-package/ and vendor/ #187

Merged
merged 5 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ module.exports = {
'test/snapshots',
'test/temporary',
'vendor/',
'.eslintrc.js',
'new-package/elm-review-package-tests/check-previews-compile.js'
'.eslintrc.js'
],
rules: {
// Style disagreements with XO.
Expand Down Expand Up @@ -112,6 +111,8 @@ module.exports = {
files: ['./new-package/**/*.js'],
rules: {
'n/no-process-exit': 'off',
'n/no-missing-require': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/unbound-method': 'off' // TODO: Fix this warning. @lishaduck just got confused.
}
}
Expand Down
19 changes: 10 additions & 9 deletions new-package/elm-review-package-tests/check-previews-compile.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/usr/bin/env node

const path = require('path');
const path = require('node:path');
const Ansi = require('./helpers/ansi');
const {execSync} = require('child_process');
const {execSync} = require('node:child_process');
const {findPreviewConfigurations} = require('./helpers/find-configurations');
// @ts-ignore - Generated file.
lishaduck marked this conversation as resolved.
Show resolved Hide resolved
const packageDependencies = require('../elm.json').dependencies;

const root = path.dirname(__dirname);

// Find all elm.json files

findPreviewConfigurations().forEach(checkThatExampleCompiles);
for (const example of findPreviewConfigurations()) {
checkThatExampleCompiles(example);
}

function checkThatExampleCompiles(exampleConfiguration) {
const exampleConfigurationElmJson = require(`${exampleConfiguration}/elm.json`);
Expand Down Expand Up @@ -49,7 +50,6 @@ and make the necessary changes to make it compile.`
}

success(exampleConfiguration);
return;
} catch {
console.log(
`An error occurred while trying to check whether the ${Ansi.yellow(
Expand All @@ -67,7 +67,7 @@ function success(config) {
}

function checkDepsAreCompatible(exampleConfiguration, previewDependencies) {
Object.entries(packageDependencies).forEach(([depName, constraint]) => {
for (const [depName, constraint] of Object.entries(packageDependencies)) {
if (!(depName in previewDependencies)) {
console.error(
`Dependency ${depName} is missing in the ${exampleConfiguration}/ configuration`
Expand All @@ -82,12 +82,13 @@ function checkDepsAreCompatible(exampleConfiguration, previewDependencies) {
previewDependencies[depName]
);
delete previewDependencies[depName];
});
}

const remainingKeys = Object.keys(previewDependencies);
if (remainingKeys.length !== 0) {
if (remainingKeys.length > 0) {
console.error(
`There are extraneous dependencies in the ${exampleConfiguration}/ configuration: ${remainingKeys}`
// prettier-ignore
Copy link
Owner

@jfmengels jfmengels Jul 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to admit I'm not fond of having disable checks (for prettier or for TS) in files that package authors will then own.
Maybe in this case, we can create a new variable const keys = remainingKeys.join(', '); above console.error(...)?
That should get rid of the need for the ignore.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You marked this as resolved, but the comment is still here. Did you apply it on a different branch maybe?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's resolve this later, let's not block all the other PRs because of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. Well, once it's all merged I can check again.

`There are extraneous dependencies in the ${exampleConfiguration}/ configuration: ${remainingKeys.join(', ')}`
);
process.exit(1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/usr/bin/env node

const path = require('path');
const path = require('node:path');
const Ansi = require('./helpers/ansi');
const {execSync} = require('child_process');
const {execSync} = require('node:child_process');
const {findPreviewConfigurations} = require('./helpers/find-configurations');
// @ts-ignore - Generated file.
const packageDependencies = require('../elm.json').dependencies;

const root = path.dirname(__dirname);

// Find all elm.json files

findPreviewConfigurations().forEach(checkThatExampleCompiles);
for (const example of findPreviewConfigurations()) {
checkThatExampleCompiles(example);
}

function checkThatExampleCompiles(exampleConfiguration) {
const exampleConfigurationElmJson = require(`${exampleConfiguration}/elm.json`);
Expand Down Expand Up @@ -49,7 +50,6 @@ and make the necessary changes to make it compile.`
}

success(exampleConfiguration);
return;
} catch {
console.log(
`An error occurred while trying to check whether the ${Ansi.yellow(
Expand All @@ -67,7 +67,7 @@ function success(config) {
}

function checkDepsAreCompatible(exampleConfiguration, previewDependencies) {
Object.entries(packageDependencies).forEach(([depName, constraint]) => {
for (const [depName, constraint] of Object.entries(packageDependencies)) {
if (!(depName in previewDependencies)) {
console.error(
`Dependency ${depName} is missing in the ${exampleConfiguration}/ configuration`
Expand All @@ -82,12 +82,13 @@ function checkDepsAreCompatible(exampleConfiguration, previewDependencies) {
previewDependencies[depName]
);
delete previewDependencies[depName];
});
}

const remainingKeys = Object.keys(previewDependencies);
if (remainingKeys.length !== 0) {
if (remainingKeys.length > 0) {
console.error(
`There are extraneous dependencies in the ${exampleConfiguration}/ configuration: ${remainingKeys}`
// prettier-ignore
`There are extraneous dependencies in the ${exampleConfiguration}/ configuration: ${remainingKeys.join(', ')}`
);
process.exit(1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/usr/bin/env node

const path = require('path');
const path = require('node:path');
const Ansi = require('./helpers/ansi');
const {execSync} = require('child_process');
const {execSync} = require('node:child_process');
const {findPreviewConfigurations} = require('./helpers/find-configurations');
// @ts-ignore - Generated file.
const packageDependencies = require('../elm.json').dependencies;

const root = path.dirname(__dirname);

// Find all elm.json files

findPreviewConfigurations().forEach(checkThatExampleCompiles);
for (const example of findPreviewConfigurations()) {
checkThatExampleCompiles(example);
}

function checkThatExampleCompiles(exampleConfiguration) {
const exampleConfigurationElmJson = require(`${exampleConfiguration}/elm.json`);
Expand Down Expand Up @@ -49,7 +50,6 @@ and make the necessary changes to make it compile.`
}

success(exampleConfiguration);
return;
} catch {
console.log(
`An error occurred while trying to check whether the ${Ansi.yellow(
Expand All @@ -67,7 +67,7 @@ function success(config) {
}

function checkDepsAreCompatible(exampleConfiguration, previewDependencies) {
Object.entries(packageDependencies).forEach(([depName, constraint]) => {
for (const [depName, constraint] of Object.entries(packageDependencies)) {
if (!(depName in previewDependencies)) {
console.error(
`Dependency ${depName} is missing in the ${exampleConfiguration}/ configuration`
Expand All @@ -82,12 +82,13 @@ function checkDepsAreCompatible(exampleConfiguration, previewDependencies) {
previewDependencies[depName]
);
delete previewDependencies[depName];
});
}

const remainingKeys = Object.keys(previewDependencies);
if (remainingKeys.length !== 0) {
if (remainingKeys.length > 0) {
console.error(
`There are extraneous dependencies in the ${exampleConfiguration}/ configuration: ${remainingKeys}`
// prettier-ignore
`There are extraneous dependencies in the ${exampleConfiguration}/ configuration: ${remainingKeys.join(', ')}`
);
process.exit(1);
}
Expand Down
4 changes: 2 additions & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
]
},
"eslint-check": {
"inputs": ["lib/*", ".eslintrc.js"]
"inputs": ["lib/*", "vendor/*", ".eslintrc.js"]
},
"eslint-fix": {
"inputs": ["lib/*", ".eslintrc.js"]
"inputs": ["lib/*", "vendor/*", ".eslintrc.js"]
},
"js-check": {
"dependsOn": ["eslint-check", "prettier-check"]
Expand Down