Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate to mocha and eslint 9 #1266

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"reporter": ["lcov"],
"include": ["packages/*/lib/**/*.ts"],
"exclude": []
}
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

59 changes: 0 additions & 59 deletions .eslintrc.json

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/nodejs-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ jobs:
- run: npm ci
- run: npm run build --if-present

- name: Run Jest
- name: Run unit tests
run: npm run unit-tests
if: matrix.node != env.NODE_COV

- name: Run Jest with coverage
run: npm run unit-tests -- --coverage
- name: Run unit tests with coverage
run: npm run unit-tests-coverage
if: matrix.node == env.NODE_COV

- name: Run Coveralls
Expand Down
7 changes: 7 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require": "ts-node/register",
"loader": "ts-node/esm",
"extensions": ["ts"],
"spec": ["**/*.test.ts"],
"watch-files": ["packages/*/lib"]
}
2 changes: 2 additions & 0 deletions bench/memory/sax-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import memwatch from '@airbnb/node-memwatch';
import { SAXParser } from '../../packages/parse5-sax-parser/dist/index.js';
import { finished } from 'parse5-test-utils/dist/common.js';

/* eslint-disable no-console */

const heapDiffMeasurement = new memwatch.HeapDiff();

let maxMemUsage = 0;
Expand Down
2 changes: 2 additions & 0 deletions bench/perf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import * as parse5 from '../../packages/parse5/dist/index.js';
import { ParserStream as parse5Stream } from '../../packages/parse5-parser-stream/dist/index.js';
import * as parse5Upstream from 'parse5';

/* eslint-disable no-console */

const hugePagePath = new URL('../../test/data/huge-page/huge-page.html', import.meta.url);
const treeConstructionPath = new URL('../../test/data/html5lib-tests/tree-construction', import.meta.url);
const saxPath = new URL('../../test/data/sax/', import.meta.url);
Expand Down
77 changes: 77 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import eslintjs from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import { configs as tseslintConfigs } from 'typescript-eslint';
import globals from 'globals';

const { configs: eslintConfigs } = eslintjs;

const sourceFiles = ['bench/**/*.js', 'scripts/**/*.ts', 'packages/*/lib/**/*.ts'];
const testFiles = ['test/**/*.{ts,js}'];
const ignoreFiles = [
'test/data/html5lib-tests',
'test/data/html5lib-tests-fork',
'packages/*/dist/',
'test/dist/',
'docs/build/',
];
const allFiles = [...sourceFiles, ...testFiles];

export default [
{
files: allFiles,
},
{
ignores: ignoreFiles,
},
{
languageOptions: {
globals: {
...globals.nodeBuiltin,
...globals.es2019,
},
},
},
eslintConfigs.recommended,
...tseslintConfigs.recommended,
{
rules: {
'no-console': 'error',
curly: ['error', 'all'],
'prefer-arrow-callback': 'error',
'one-var': ['error', 'never'],
'no-var': 'error',
'prefer-const': 'error',
'object-shorthand': 'error',
'prefer-destructuring': [
'error',
{
object: true,
array: false,
},
],
'prefer-template': 'error',
'arrow-body-style': ['error', 'as-needed'],
},
},
{
files: testFiles,
languageOptions: {
globals: {
...globals.mocha,
},
},
},
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/consistent-type-imports': 'error',

'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
},
},
eslintConfigPrettier,
];
Loading