Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
zckrs committed Mar 5, 2024
1 parent fd10d8c commit 074ff5c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "https://www.radiofrance.fr"
},
"engines": {
"node": ">=16"
"node": ">=18"
},
"scripts": {
"lint": "eslint .",
Expand Down Expand Up @@ -46,22 +46,22 @@
"simple"
],
"dependencies": {
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"eslint-config-xo": "^0.43.1",
"eslint-config-xo-typescript": "^1.0.1",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"eslint-config-xo": "^0.44.0",
"eslint-config-xo-typescript": "^3.0.0",
"eslint-plugin-promise": "^6.0.0",
"typescript": ">=5.0.2"
},
"devDependencies": {
"ava": "^3.7.1",
"ava": "^6.1.2",
"eslint": "^8.52.0"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": ">=6.0.0",
"@typescript-eslint/parser": ">=6.0.0",
"eslint": ">=8.0.0",
"typescript": ">=5.0.2"
"@typescript-eslint/eslint-plugin": ">=7.0.2",
"@typescript-eslint/parser": ">=7.0.2",
"eslint": ">=8.56.0",
"typescript": ">=5.0.0"
},
"eslintConfig": {
"extends": "xo",
Expand Down
Empty file added test/_x.ts
Empty file.
24 changes: 12 additions & 12 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
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(str, config) {
const linter = new ESLint({
useEslintrc: false,
configFile: path.join(__dirname, config),
overrideConfig: config,
});

return linter.executeOnText(string, path.join(__dirname, '../_x.ts')).results[0].messages;
return (await linter.lintText(str, {filePath: 'test/_x.ts'}))[0].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);
});
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"compilerOptions": {
"strict": true,
},
"include": [
"test"
]
Expand Down

0 comments on commit 074ff5c

Please sign in to comment.