test: eslint for tests

This commit is contained in:
Barış Soner Uşaklı
2025-04-22 17:15:48 -04:00
parent b57ce29dc6
commit f864a5a4ac
4 changed files with 15 additions and 12 deletions

View File

@@ -2,8 +2,11 @@
import serverConfig from 'eslint-config-nodebb';
import publicConfig from 'eslint-config-nodebb/public';
import commonRules from 'eslint-config-nodebb/common';
import { defineConfig } from 'eslint/config';
import stylisticJs from '@stylistic/eslint-plugin-js'
import js from '@eslint/js';
import globals from 'globals';
export default defineConfig([
@@ -30,6 +33,11 @@ export default defineConfig([
},
// tests
{
plugins: {
js,
'@stylistic/js': stylisticJs,
},
extends: ['js/recommended'],
files: ['test/**/*.js'],
languageOptions: {
ecmaVersion: 2020,
@@ -44,12 +52,13 @@ export default defineConfig([
after: 'readonly',
afterEach: 'readonly',
},
},
},
rules: {
'no-unused-vars': 'off',
...commonRules,
'no-unused-vars': 'off',
'no-prototype-builtins': 'off',
}
},
},
...publicConfig,
...serverConfig
]);

View File

@@ -163,7 +163,7 @@
"coveralls": "3.1.1",
"@eslint/js": "9.25.1",
"@stylistic/eslint-plugin-js": "4.2.0",
"eslint-config-nodebb": "1.1.3",
"eslint-config-nodebb": "1.1.4",
"eslint-plugin-import": "2.31.0",
"grunt": "1.6.1",
"grunt-contrib-watch": "1.1.0",

View File

@@ -244,7 +244,7 @@ describe('Topic thumbs', () => {
it('should also work with UUIDs', async () => {
await topics.thumbs.associate({
id: uuid,
path: `/files/test.png`
path: `/files/test.png`,
});
await topics.thumbs.delete(uuid, '/files/test.png');
@@ -268,13 +268,6 @@ describe('Topic thumbs', () => {
assert.strictEqual(await file.exists(thumbPaths[0]), true);
});
// it('should handle an array of relative paths', async () => {
// await topics.thumbs.associate({ id: 1, path: thumbPaths[0] });
// await topics.thumbs.associate({ id: 1, path: thumbPaths[1] });
// await topics.thumbs.delete(1, [relativeThumbPaths[0], relativeThumbPaths[1]]);
// });
it('should have no more thumbs left', async () => {
const associated = await db.isSortedSetMembers(`topic:1:thumbs`, [relativeThumbPaths[0], relativeThumbPaths[1]]);
assert.strictEqual(associated.some(Boolean), false);

View File

@@ -285,6 +285,7 @@ describe('Utility Methods', () => {
});
it('should return passed in value if invalid', (done) => {
// eslint-disable-next-line no-loss-of-precision
const bigInt = -111111111111111111;
const result = utils.toISOString(bigInt);
assert.equal(bigInt, result);