UNPKG

@team23/eslint-config-team23-ts

Version:

A set of eslint rules used by TEAM23 for standard ts projects

87 lines 3.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createTSEslintConfig = void 0; const tslib_1 = require("tslib"); const typescript_eslint_1 = tslib_1.__importDefault(require("typescript-eslint")); const tseslint_config_js_1 = tslib_1.__importDefault(require("./config/tseslint-config.cjs")); const stylistic_config_js_1 = tslib_1.__importDefault(require("./config/stylistic-config.cjs")); const tseslint_stylistic_config_js_1 = tslib_1.__importDefault(require("./config/tseslint-stylistic-config.cjs")); const jsdoc_config_1 = tslib_1.__importDefault(require("./config/jsdoc-config.cjs")); const GLOB_TS = '**/*.?([cm])ts'; const GLOB_TSX = '**/*.?([cm])tsx'; const fileBasedModificationConfigs = [ { name: 'team23/type-script/core/file-based/cypress', files: ['cypress.config.ts', 'cypress.**.config.ts'], rules: { 'no-console': 'off', }, }, { name: 'team23/type-script/core/file-based/page-object', files: ['*.po.ts'], rules: { '@typescript-eslint/explicit-function-return-type': 'off', }, }, { name: 'team23/type-script/core/file-based/mocks', files: ['*.spec.ts', '*.spec.tsx', '**/__mocks__/**/*.ts', '**/__mocks__/**/*.tsx'], rules: { '@typescript-eslint/no-magic-numbers': 'off', '@typescript-eslint/no-empty-function': 'off', 'max-lines': 'off', }, }, ]; /** * Creates an ESLint configuration tailored for TypeScript projects with optional settings. * * @param [options] - Optional configuration settings. * * @returns Array of ESLint configuration objects. */ function createTSEslintConfig(options) { var _a; const { fileExtensions = [], tsconfigPath = undefined, } = options !== null && options !== void 0 ? options : {}; const files = (_a = options === null || options === void 0 ? void 0 : options.files) !== null && _a !== void 0 ? _a : [ GLOB_TS, GLOB_TSX, ...fileExtensions.map(extension => `**/*.${extension}`), ]; const setupConfig = { name: 'team23/type-script/setup', ignores: ['polyfills.ts', 'jest.config.ts', 'dist/**', 'node_modules/**'], plugins: { // @ts-expect-error tseslint uses own not so strict type '@typescript-eslint': typescript_eslint_1.default.plugin, }, languageOptions: { // @ts-expect-error typing mismatch: tseslint provides extended parser parser: typescript_eslint_1.default.parser, parserOptions: { sourceType: 'module', parser: typescript_eslint_1.default.parser, extraFileExtensions: fileExtensions.map(extension => `.${extension}`), projectService: { allowDefaultProject: ['./*js'], defaultProject: tsconfigPath, }, tsconfigRootDir: process.cwd(), }, }, }; return typescript_eslint_1.default.config( // do not set with extends, parser will not be configured correctly setupConfig, { files, extends: [ ...tseslint_config_js_1.default, ...tseslint_stylistic_config_js_1.default, ...stylistic_config_js_1.default, ...jsdoc_config_1.default, ], }, ...fileBasedModificationConfigs); } exports.createTSEslintConfig = createTSEslintConfig; //# sourceMappingURL=index.cjs.map