-
Notifications
You must be signed in to change notification settings - Fork 0
Compare Final Config for Testing #10
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9a48f28
Make test work on other machines
FSVetaz e9220ec
Compare Final Config for testing
FSVetaz 82b2b2f
ignore all new-lint...
FSVetaz 9a1a4c3
This shouldn't be committed
FSVetaz 920e9a6
Make it work for other machines
FSVetaz 1f9bcdc
fix up test
FSVetaz 7594808
Naming, location, and documentation updates
skye2k2 2f84e80
Don't use sed
FSVetaz d0aeb8a
Cleanup
skye2k2 3dce78a
Add a helpful caveat for JSDoc
skye2k2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ | |
/reports/** | ||
analysis.json | ||
npm-debug.log | ||
/demo/test/snapshots/*results.txt | ||
/demo/test/snapshots/local* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// NOTE: This test file runs against untracked files in an attempt to be an early warning system against making changes that would lose configuration that we care about. See the README for more information. | ||
|
||
import test from 'ava'; | ||
const fileManager = require('file-manager-js'); | ||
|
||
function processFile (t, filename) { | ||
// Run previously via npm test, save off results, and read output | ||
return fileManager.readFile(`./demo/test/snapshots/${filename}`) | ||
.then((content) => { | ||
const output = content.toString(); // content is instance of Buffer, so it needs to be parsed | ||
return t.snapshot(output); | ||
}) | ||
.catch((err) => { | ||
console.log(err); // eslint-disable-line no-console -- Tests use the console. | ||
return t.fail(); | ||
}); | ||
} | ||
|
||
test('Should apply our custom linting rules consistently', async t => { | ||
return processFile(t, 'local-linting-output.txt'); | ||
}); | ||
|
||
test('Should apply a consistent overall eslint configuration', async t => { | ||
return processFile(t, 'local-linting-final-config.json'); // If this fails, go cry to mommy | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Process the exported linting results and final configuration files: | ||
// Sort final configuration rules alphabetically to compare changes easier. | ||
// Remove any developer-specific directory paths for both files. | ||
|
||
/* eslint no-console: "off" -- node scripts use the console, so disable for the whole file */ | ||
|
||
const finalConfig = require('./local-linting-final-config.json'); | ||
|
||
const FS = require('fs'); | ||
|
||
const formattedRules = Object.fromEntries( | ||
Object.entries(finalConfig?.rules ?? {}).sort(([ruleNameA], [ruleNameB]) => { | ||
if (ruleNameA > ruleNameB) return 1; | ||
if (ruleNameB > ruleNameA) return -1; | ||
return 0; | ||
}) | ||
); | ||
|
||
FS.writeFile( | ||
'./demo/test/snapshots/local-linting-final-config.json', | ||
JSON.stringify( | ||
{ ...finalConfig, rules: formattedRules, parser: finalConfig.parser?.split('eslint-config-tree')[1] }, | ||
null, | ||
2 | ||
), | ||
(err) => { | ||
if (err) console.log('There was an error writing to local-linting-final-config.json file:', err); | ||
} | ||
); | ||
|
||
FS.readFile('./demo/test/snapshots/local-linting-output.txt', 'utf8', (err, eslintOutput) => { | ||
if (err) { | ||
console.log('There was an error reading local-linting-output.txt', err); | ||
} else { | ||
FS.writeFile( | ||
'./demo/test/snapshots/local-linting-output.txt', | ||
eslintOutput.replace(/.*demo\//g, ''), | ||
(err2) => { | ||
if (err2) console.log('There was an error writing to local-linting-output.txt file:', err); | ||
} | ||
); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh that is interesting