Added files

This commit is contained in:
Toastie (DCS Team) 2024-10-01 19:04:25 +13:00
parent 98031f6975
commit f0c337f904
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
10 changed files with 2000 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
node_modules/

86
configs/javascript.js Normal file
View file

@ -0,0 +1,86 @@
import { fixupPluginRules } from '@eslint/compat';
import _import from 'eslint-plugin-import';
const jsRules = {
'indent': ['warn', 'tab', {
'SwitchCase': 1,
'MemberExpression': 1,
'flatTernaryExpressions': true,
'ArrayExpression': 'first',
'ObjectExpression': 'first',
}],
'eol-last': ['error', 'always'],
'semi': ['error', 'always'],
'semi-spacing': ['error', { 'before': false, 'after': true }],
'quotes': ['warn', 'single'],
'comma-dangle': ['warn', 'always-multiline'],
'comma-spacing': ['error', { 'before': false, 'after': true }],
'array-bracket-spacing': ['error', 'never'],
'keyword-spacing': ['error', {
'before': true,
'after': true,
}],
'key-spacing': ['error', {
'beforeColon': false,
'afterColon': true,
}],
'arrow-spacing': ['error', {
'before': true,
'after': true,
}],
'brace-style': ['error', '1tbs', {
'allowSingleLine': true,
}],
'padded-blocks': ['error', 'never'],
/* TODO: If you do not use path alias, a warning will be issued.
'no-restricted-imports': ['warn', {
'patterns': [
],
}],
*/
'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
'no-multi-spaces': ['error'],
'no-var': ['error'],
'prefer-arrow-callback': ['error'],
'no-throw-literal': ['error'],
'no-param-reassign': ['warn'],
'no-constant-condition': ['warn'],
'no-empty-pattern': ['warn'],
'no-async-promise-executor': ['off'],
'no-useless-escape': ['off'],
'no-multiple-empty-lines': ['error', { 'max': 1 }],
'no-control-regex': ['warn'],
'no-empty': ['warn'],
'no-inner-declarations': ['off'],
'no-sparse-arrays': ['off'],
'nonblock-statement-body-position': ['error', 'beside'],
'object-curly-spacing': ['error', 'always'],
'space-infix-ops': ['error'],
'space-before-blocks': ['error', 'always'],
'padding-line-between-statements': [
'error',
{ 'blankLine': 'always', 'prev': 'function', 'next': '*' },
{ 'blankLine': 'always', 'prev': '*', 'next': 'function' },
],
'lines-between-class-members': 'off',
'import/no-unresolved': ['off'],
'import/no-default-export': ['warn'],
'import/order': ['warn', {
'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
}],
};
export default {
plugins: {
import: fixupPluginRules(_import),
},
settings: {
/** @see https://github.com/import-js/eslint-plugin-import/issues/2556#issuecomment-1419518561 */
'import/parsers': {
'@typescript-eslint/parser': ['.js', '.cjs', '.mjs', '.jsx'],
},
},
rules: {
...jsRules,
},
};

35
configs/recommended.js Normal file
View file

@ -0,0 +1,35 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { fixupConfigRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import javascript from './javascript.js';
import typescript from './typescript.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
export default [
...fixupConfigRules(compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
// TODO: When enabled, when you import in a .ts file
// parserPath or languageOptions.parser is required!
// This will appear, so disable the following:
// 'plugin:import/recommended',
'plugin:import/typescript',
)),
{
files: ['**/*.js', '**/*.cjs', '**/*.mjs', '**/*.jsx'],
...javascript,
},
{
files: ['**/*.ts', '**/*.tsx'],
...typescript,
},
];

63
configs/typescript.js Normal file
View file

@ -0,0 +1,63 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import { fixupPluginRules } from '@eslint/compat';
import _import from 'eslint-plugin-import';
import javascript from './javascript.js';
const tsRules = {
/* It seems that typescript-eslint does not support enforce.
'@typescript-eslint/lines-between-class-members': ['error', {
enforce: [{
blankLine: 'always',
prev: 'method',
next: '*',
}],
}],
*/
'@typescript-eslint/func-call-spacing': ['error', 'never'],
'@typescript-eslint/no-explicit-any': ['warn'],
'@typescript-eslint/no-unused-vars': ['warn'],
'@typescript-eslint/no-unnecessary-condition': ['warn'],
'@typescript-eslint/no-var-requires': ['warn'],
'@typescript-eslint/no-inferrable-types': ['warn'],
'@typescript-eslint/no-empty-function': ['off'],
'@typescript-eslint/no-non-null-assertion': ['warn'],
'@typescript-eslint/explicit-function-return-type': ['off'],
'@typescript-eslint/no-misused-promises': ['error', {
'checksVoidReturn': false,
}],
'@typescript-eslint/consistent-type-imports': 'off',
'@typescript-eslint/prefer-nullish-coalescing': [
'warn',
],
'@typescript-eslint/naming-convention': [
'error',
{
'selector': 'typeLike',
'format': ['PascalCase'],
},
{
'selector': 'typeParameter',
'format': [],
},
],
};
export default {
plugins: {
'@typescript-eslint': fixupPluginRules(typescriptEslint),
import: fixupPluginRules(_import),
},
languageOptions: {
parser: tsParser,
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
},
rules: {
...javascript.rules,
...tsRules,
},
};

32
eslint.config.js Normal file
View file

@ -0,0 +1,32 @@
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import pluginValkyrie from './index.js';
export default [
...pluginValkyrie.configs['recommended'],
{
files: ['**/*.js', '**/*.jsx'],
languageOptions: {
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
},
},
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
parserOptions: {
ecmaVersion: 'latest',
parser: tsParser,
project: ['./tsconfig.json'],
sourceType: 'module',
tsconfigRootDir: import.meta.dirname,
},
},
},
];

19
index.js Normal file
View file

@ -0,0 +1,19 @@
import javascript from './configs/javascript.js';
import recommended from './configs/recommended.js';
import typescript from './configs/typescript.js';
import packageConfig from './package.json' with { type: 'json' };
const plugin = {
meta: {
name: packageConfig.name,
version: packageConfig.version,
},
configs: {
javascript,
recommended,
typescript,
},
};
export default plugin;

32
package.json Normal file
View file

@ -0,0 +1,32 @@
{
"name": "@valkyriecoms/eslint-plugin",
"version": "2.0.3",
"description": "An ESLint plugin designed for Valkyriecoms developers",
"author": "Toastie <toastie@dragonschildstudios.com",
"license": "MIT",
"repository": "https://toastielab.dev/Valkyriecoms/eslint-plugin-valkyriecoms.git",
"bugs": "https://toastielab.dev/Valkyriecoms/eslint-plugin-valkyriecoms/issues",
"type": "module",
"main": "index.js",
"scripts": {
"eslint": "eslint ./**/*.{js,jsx,ts,tsx}"
},
"peerDependencies": {
"@eslint/compat": ">= 1",
"@typescript-eslint/eslint-plugin": ">= 7",
"@typescript-eslint/parser": ">= 7",
"eslint": ">= 8",
"eslint-plugin-import": ">= 2",
"globals": ">= 15"
},
"devDependencies": {
"@eslint/compat": "^1.1.0",
"@types/node": "^20.14.8",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"eslint": "^9.5.0",
"eslint-plugin-import": "^2.29.1",
"globals": "^15.6.0"
},
"packageManager": "pnpm@8.15.6+sha512.77b89e9be77a2b06ad8f403a19cae5e22976f61023f98ad323d5c30194958ebc02ee0a6ae5d13ee454f6134e4e8caf29a05f0b1a0e1d2b17bca6b6a1f1159f86"
}

1718
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load diff

2
test/index.ts Normal file
View file

@ -0,0 +1,2 @@
const hgoe = 'fuga';
console.log(hgoe);

12
tsconfig.json Normal file
View file

@ -0,0 +1,12 @@
{
"compilerOptions": {
"allowJs": true,
"strictNullChecks": true,
"types": [
"node"
]
},
"include": [
"**/*.ts"
]
}