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

View File

@@ -163,7 +163,7 @@
"coveralls": "3.1.1", "coveralls": "3.1.1",
"@eslint/js": "9.25.1", "@eslint/js": "9.25.1",
"@stylistic/eslint-plugin-js": "4.2.0", "@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", "eslint-plugin-import": "2.31.0",
"grunt": "1.6.1", "grunt": "1.6.1",
"grunt-contrib-watch": "1.1.0", "grunt-contrib-watch": "1.1.0",

View File

@@ -244,7 +244,7 @@ describe('Topic thumbs', () => {
it('should also work with UUIDs', async () => { it('should also work with UUIDs', async () => {
await topics.thumbs.associate({ await topics.thumbs.associate({
id: uuid, id: uuid,
path: `/files/test.png` path: `/files/test.png`,
}); });
await topics.thumbs.delete(uuid, '/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); 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 () => { it('should have no more thumbs left', async () => {
const associated = await db.isSortedSetMembers(`topic:1:thumbs`, [relativeThumbPaths[0], relativeThumbPaths[1]]); const associated = await db.isSortedSetMembers(`topic:1:thumbs`, [relativeThumbPaths[0], relativeThumbPaths[1]]);
assert.strictEqual(associated.some(Boolean), false); assert.strictEqual(associated.some(Boolean), false);

View File

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