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'); 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 = { module.exports = {
extends: './configs/node.js', extends: './configs/node.js',
ignorePatterns: [ '/example/wrong.*' ], ignorePatterns: [ '/example/wrong.*' ],

View File

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

View File

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

View File

@ -5,5 +5,7 @@ module.exports = {
object:{spacing:'required!'}, 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" "eslint-plugin-import": "^2.27.5"
}, },
"peerDependencies": { "peerDependencies": {
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.2.1",
"eslint": "^7.9.0 || ^8.0.0", "eslint": "^7.9.0 || ^8.0.0",
"eslint-plugin-svelte": "^2.32.4" "eslint-plugin-svelte": "^2.32.4",
"typescript": "^5.0.0"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"@typescript-eslint/parser": {
"optional": true
},
"@typescript-eslint/eslint-plugin": {
"optional": true
},
"eslint-plugin-svelte": { "eslint-plugin-svelte": {
"optional": true "optional": true
},
"typescript": {
"optional": true
} }
}, },
"devDependencies": { "devDependencies": {