-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(betterer 🐛): handle -1 column fixes #1202
- Loading branch information
1 parent
da704f2
commit c1336e1
Showing
3 changed files
with
114 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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,40 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`betterer > should handle eslint rules that mark the entire line of code 1`] = ` | ||
"// BETTERER RESULTS V2. | ||
// | ||
// If this file contains merge conflicts, use \`betterer merge\` to automatically resolve them: | ||
// https://phenomnomnominal.github.io/betterer/docs/results-file/#merge | ||
// | ||
exports[\`test\`] = { | ||
value: \`{ | ||
"src/index.ts:3395480044": [ | ||
[0, 0, 27, "Unexpected unlimited \\'eslint-disable-next-line\\' comment. Specify some rule names to disable.", "1912322876"], | ||
[0, 0, 27, "Unexpected undescribed directive comment. Include descriptions to explain why the comment is necessary.", "1912322876"] | ||
] | ||
}\` | ||
}; | ||
" | ||
`; | ||
exports[`betterer > should handle eslint rules that mark the entire line of code 2`] = ` | ||
[ | ||
"🌟 Betterer (0ms): | ||
", | ||
"🌟 Betterer (0ms): 1 test running... | ||
🤔 test: running "test"! | ||
", | ||
"🌟 Betterer (0ms): 1 test running... | ||
✅ test: "test" got checked for the first time! (2 issues) 🎉 | ||
", | ||
"🎉 Betterer (0ms): 1 test done! | ||
✅ test: "test" got checked for the first time! (2 issues) 🎉 | ||
", | ||
"🎉 Betterer (0ms): 1 test done! | ||
✅ test: "test" got checked for the first time! (2 issues) 🎉 | ||
1 test got checked. 🤔 | ||
1 test got checked for the first time! 🎉 | ||
", | ||
] | ||
`; |
This file contains 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,69 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { createFixture } from './fixture.js'; | ||
|
||
describe('betterer', () => { | ||
// See: https://github.com/phenomnomnominal/betterer/issues/1202 | ||
it('should handle eslint rules that mark the entire line of code', async () => { | ||
const { betterer } = await import('@betterer/betterer'); | ||
|
||
const { logs, paths, readFile, cleanup, resolve, writeFile } = await createFixture('eslint-no-column-rule', { | ||
'.betterer.ts': ` | ||
import { eslint } from '@betterer/eslint'; | ||
export default { | ||
test: () => eslint({ | ||
rules: { | ||
'@eslint-community/eslint-comments/require-description': 'error' | ||
} | ||
}) | ||
.include('./src/**/*.ts') | ||
}; | ||
`, | ||
'eslint.config.js': ` | ||
import eslint from '@eslint/js'; | ||
import tslint from 'typescript-eslint'; | ||
import comments from '@eslint-community/eslint-plugin-eslint-comments/configs'; | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
export default tslint.config( | ||
eslint.configs.recommended, | ||
...tslint.configs.recommended, | ||
comments.recommended, | ||
{ | ||
languageOptions: { | ||
parserOptions: { | ||
project: "./tsconfig.json", | ||
tsconfigRootDir: path.dirname(fileURLToPath(import.meta.url)) | ||
}, | ||
}, | ||
}, | ||
{ rules: { '@eslint-community/eslint-comments/require-description': 'off' } } | ||
); | ||
`, | ||
'tsconfig.json': ` | ||
{ | ||
"include": ["./src/**/*"] | ||
} | ||
` | ||
}); | ||
|
||
const configPaths = [paths.config]; | ||
const resultsPath = paths.results; | ||
const indexPath = resolve('./src/index.ts'); | ||
|
||
await writeFile(indexPath, `// eslint-disable-next-line\ndebugger;`); | ||
|
||
await betterer({ configPaths, resultsPath, workers: false }); | ||
|
||
const result = await readFile(resultsPath); | ||
|
||
expect(result).toMatchSnapshot(); | ||
|
||
expect(logs).toMatchSnapshot(); | ||
|
||
await cleanup(); | ||
}); | ||
}); |