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

tools: lint typescript files #55709

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion doc/eslint.config_partial.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const globals = requireEslintTool('globals');

export default [
{
files: ['doc/**/*.md/*.{js,mjs,cjs}'],
files: ['doc/**/*.md/*.{js,mjs,cjs,ts,mts,cts}'],
rules: {
// Ease some restrictions in doc examples.
'no-restricted-properties': 'off',
Expand All @@ -23,6 +23,8 @@ export default [
},
],
'no-undef': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-vars': 'off',
RedYetiDev marked this conversation as resolved.
Show resolved Hide resolved
'no-unused-expressions': 'off',
'no-unused-vars': 'off',
'symbol-description': 'off',
Expand Down
16 changes: 14 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const babelPluginSyntaxImportAttributes = resolveEslintTool('@babel/plugin-synta
const jsdoc = requireEslintTool('eslint-plugin-jsdoc');
const markdown = requireEslintTool('eslint-plugin-markdown');
const stylisticJs = requireEslintTool('@stylistic/eslint-plugin-js');
const tseslint = requireEslintTool('typescript-eslint');

nodeCore.RULES_DIR = fileURLToPath(new URL('./tools/eslint-rules', import.meta.url));

Expand Down Expand Up @@ -61,7 +62,7 @@ export default [
js.configs.recommended,
jsdoc.configs['flat/recommended'],
{
files: ['**/*.{js,cjs}'],
files: ['**/*.{js,cjs,ts,cts}'],
languageOptions: {
// The default is `commonjs` but it's not supported by the Babel parser.
sourceType: 'script',
Expand Down Expand Up @@ -326,7 +327,7 @@ export default [
processor: 'markdown/markdown',
},
{
files: ['**/*.md/*.{js,cjs}'],
files: ['**/*.md/*.{js,cjs,ts,cts}'],
languageOptions: {
parserOptions: {
ecmaFeatures: { impliedStrict: true },
Expand Down Expand Up @@ -376,6 +377,17 @@ export default [
] },
},
// #endregion
{
files: ['**/*.{ts,mts,cts}'],
...tseslint.configs.base,
rules: {
...tseslint.configs.eslintRecommended.rules,
// Index 0 contains the base configuration,
// index 1 provides eslint-specific overrides,
// and index 2 includes the recommended rules.
...tseslint.configs.recommended[2].rules,
RedYetiDev marked this conversation as resolved.
Show resolved Hide resolved
},
},
// #region partials
...benchmarkConfig,
...docConfig,
Expand Down
10 changes: 5 additions & 5 deletions test/eslint.config_partial.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const globals = requireEslintTool('globals');

export default [
{
files: ['test/**/*.{js,mjs,cjs}'],
files: ['test/**/*.{js,mjs,cjs,ts,mts,cts}'],
languageOptions: {
globals: {
...globals.node,
Expand Down Expand Up @@ -122,9 +122,9 @@ export default [
},
{
files: [
'test/es-module/**/*.{js,mjs}',
'test/parallel/**/*.{js,mjs}',
'test/sequential/**/*.{js,mjs}',
'test/es-module/**/*.{js,mjs,cjs,ts,mts,cts}',
'test/parallel/**/*.{js,mjs,cjs,ts,mts,cts}',
'test/sequential/**/*.{js,mjs,cjs,ts,mts,cts}',
],
rules: {
'@stylistic/js/comma-dangle': [
Expand All @@ -141,7 +141,7 @@ export default [
},
{
files: [
'test/{common,wpt}/**/*.{js,mjs,cjs}',
'test/{common,wpt}/**/*.{js,mjs,cjs,ts,mts,cts}',
'test/eslint.config_partial.mjs',
],
rules: {
Expand Down
18 changes: 16 additions & 2 deletions tools/eslint/eslint.config_partial.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const globals = requireEslintTool('globals');

export default [
{
files: ['tools/**/*.{js,mjs,cjs}'],
files: ['tools/**/*.{js,mjs,cjs,ts,mts,cts}'],
languageOptions: {
globals: {
...globals.node,
Expand All @@ -19,11 +19,25 @@ export default [
allow: ['child_process'],
},
],
'prefer-arrow-callback': 'error',
},
},
{
files: ['tools/**/*.{ts,mts,cts}'],
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ args: 'after-used' },
],
},
},
{
files: ['tools/**/*.{js,mjs,cjs}'],
rules: {
'no-unused-vars': [
'error',
{ args: 'after-used' },
],
'prefer-arrow-callback': 'error',
},
},
];
Loading
Loading