Added support for TypeScript codebases

This commit is contained in:
Romein van Buren 2023-08-07 17:50:06 +02:00
parent c29b5c06cf
commit b5b3ccac67
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
6 changed files with 999 additions and 19 deletions

View File

@ -2,7 +2,12 @@
const svelteConfig = require('./configs/svelte.js');
/** @type {import('eslint').Linter.Config} */
/**
* Don't import this! It is the configuration for the yeslint! code and is not
* meant to be used elsewhere. Please refer to the readme.
*
* @type {import('eslint').Linter.Config}
*/
module.exports = {
extends: './configs/node.js',
ignorePatterns: [ '/example/wrong.*' ],

View File

@ -1,5 +1,13 @@
'use strict';
let typescriptInstalled = false;
try {
require('typescript');
typescriptInstalled = true;
}
catch { /* not installed */ }
/**
* Generic ESLint configuration for all modern JavaScript runtimes.
*
@ -20,9 +28,7 @@ const generic = {
rules: {
'no-undef': [
'error',
{
typeof: true,
},
{ typeof: true },
],
'require-atomic-updates': 0,
indent: [
@ -47,11 +53,6 @@ const generic = {
'error',
'always',
],
'array-element-newline': [ 'warn' ],
'array-bracket-newline': [
'warn',
{ minItems: 2 },
],
'arrow-body-style': [
'error',
'as-needed',
@ -92,9 +93,7 @@ const generic = {
'keyword-spacing': 'error',
'key-spacing': [
'warn',
{
beforeColon: false,
},
{ beforeColon: false },
],
'linebreak-style': [
'error',
@ -211,6 +210,12 @@ const generic = {
'no-nested-ternary': 'error',
'no-lonely-if': 'error',
},
overrides: typescriptInstalled ? [ {
files: '**/*.ts',
parser: '@typescript-eslint/parser',
plugins: [ '@typescript-eslint' ],
extends: [ 'plugin:@typescript-eslint/recommended' ],
} ] : [],
};
module.exports = generic;

View File

@ -11,4 +11,10 @@ module.exports = {
console.log(password);
},
],
arrays: [
1,
2,
3,
],
};

View File

@ -5,5 +5,7 @@ module.exports = {
object:{spacing:'required!'},
functions: [( env )=> console.log(env.password),function ({password}) { console.log( password )}]
functions: [( env )=> console.log(env.password),function ({password}) { console.log( password )}],
arrays: [1,2,3]
}

960
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -27,12 +27,24 @@
"eslint-plugin-import": "^2.27.5"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.2.1",
"eslint": "^7.9.0 || ^8.0.0",
"eslint-plugin-svelte": "^2.32.4"
"eslint-plugin-svelte": "^2.32.4",
"typescript": "^5.0.0"
},
"peerDependenciesMeta": {
"@typescript-eslint/parser": {
"optional": true
},
"@typescript-eslint/eslint-plugin": {
"optional": true
},
"eslint-plugin-svelte": {
"optional": true
},
"typescript": {
"optional": true
}
},
"devDependencies": {