tic-tac-toe-optimal-turn
Version:
Tic-tac-toe optimal turn package based on alpha-beta algorithm.
91 lines (87 loc) • 2.72 kB
JavaScript
import globals from "globals";
import pluginJs from "@eslint/js";
import pluginTs from "typescript-eslint";
import pluginJest from "eslint-plugin-jest"
import { fixupPluginRules } from "@eslint/compat";
import { FlatCompat } from "@eslint/eslintrc";
import { fileURLToPath } from 'url';
import * as path from 'path';
const project = "./tsconfig.json";
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
const compat = new FlatCompat({
baseDirectory: dirname,
recommendedConfig: pluginJs.configs.recommended,
});
function legacyPlugin(name, alias = name) {
const plugin = compat.plugins(name)[0]?.plugins?.[alias];
if (!plugin) {
throw new Error(`Unable to resolve plugin ${name} and/or alias ${alias}`);
}
return fixupPluginRules(plugin);
}
/** @type {import('eslint').Linter.Config[]} */
export default [
{files: ["**/*.{js,mjs,cjs,ts}"]},
{languageOptions: { globals: {...globals.browser, ...globals.node} }},
pluginJs.configs.recommended,
...pluginTs.configs.recommended,
...compat.extends("plugin:import/typescript"),
{
languageOptions: {
globals: pluginJest.environments.globals.globals,
parserOptions: {
project,
tsconfigRootDir: import.meta.dirname,
},
},
settings: {
"import/resolver": {
typescript: {
alwaysTryTypes: true,
project,
}
},
},
plugins: {
import: legacyPlugin("eslint-plugin-import", "import"),
jest: pluginJest
},
rules: {
'arrow-parens': 'off',
'consistent-return': 'off',
curly: ['error', 'all'],
'import/extensions': [
'error',
{css: 'always', json: 'always', scss: 'always', svg: 'always'},
],
'import/no-duplicates': 'off',
'import/order': 'off',
'import/prefer-default-export': 'off',
'max-lines': ['warn', 300],
'no-console': ['warn', {allow: ['warn', 'error']}],
'no-debugger': 'off',
'no-duplicate-imports': 'error',
'no-empty-pattern': 'off',
'no-nested-ternary': 'error',
'no-undef': 'warn',
'no-unused-vars': 'off',
'no-var': 'error',
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
'padding-line-between-statements': [
'error',
{blankLine: 'always', next: 'return', prev: '*'},
{blankLine: 'always', next: '*', prev: ['const', 'let', 'var']},
{
blankLine: 'any',
next: ['const', 'let', 'var'],
prev: ['const', 'let', 'var'],
},
]
},
}
];