This repository has been archived by the owner on Mar 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add eslint-plugin-import * Add eslint-plugin-simple-import-sort * Reactivate rule promise/no-return-wrap * Use override for TS files * Remove override for test files in TS * Require node 18 * Add CI with Github * Fix test * Bump deps
- Loading branch information
Showing
7 changed files
with
70 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: CI | ||
on: | ||
- push | ||
- pull_request | ||
jobs: | ||
test: | ||
name: Node.js ${{ matrix.node-version }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: | ||
- 20 | ||
- 18 | ||
- 16 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: npm test |
This file was deleted.
Oops, something went wrong.
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
Empty file.
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 |
---|---|---|
@@ -1,27 +1,29 @@ | ||
const path = require('path'); | ||
const test = require('ava'); | ||
const eslint = require('eslint'); | ||
const {ESLint} = require('eslint'); | ||
|
||
const config = '../index.js'; | ||
const config = require('../index.js'); | ||
|
||
const hasRule = (errors, ruleId) => errors.some(x => x.ruleId === ruleId); | ||
|
||
function runEslint(string, config) { | ||
const linter = new eslint.CLIEngine({ | ||
async function runEslint(string, config) { | ||
const eslint = new ESLint({ | ||
useEslintrc: false, | ||
configFile: path.join(__dirname, config), | ||
overrideConfig: config, | ||
}); | ||
|
||
return linter.executeOnText(string, path.join(__dirname, '../_x.ts')).results[0].messages; | ||
const [firstResult] = await eslint.lintText(string, {filePath: 'test/_x.ts'}); | ||
|
||
return firstResult.messages; | ||
} | ||
|
||
// Cant be fixed due https://github.com/typescript-eslint/typescript-eslint/issues/885 | ||
test.failing('main', t => { | ||
const errors = runEslint('const foo: number = 5;', config); | ||
test('should throw error no-inferrable-types', async t => { | ||
const errors = await runEslint('const foo: number = 5;\n', config); | ||
t.true(hasRule(errors, '@typescript-eslint/no-inferrable-types'), JSON.stringify(errors)); | ||
t.is(errors.length, 1); | ||
}); | ||
|
||
test.failing('main error no-console', t => { | ||
const errors = runEslint('\'use strict\';\nconst x = true;\n\nif (x) {\n console.log();\n}\n', config); | ||
test('should throw error no-console', async t => { | ||
const errors = await runEslint('\'use strict\';\nconst x = true;\n\nif (x) {\n console.log();\n}\n', config); | ||
t.true(hasRule(errors, 'no-console'), JSON.stringify(errors)); | ||
t.is(errors.length, 1); | ||
}); |
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
}, | ||
"include": [ | ||
"test" | ||
] | ||
|