UNPKG

@vis.gl/dev-tools

Version:

Dev tools for vis.gl frameworks

8 lines (7 loc) 9.67 kB
{ "version": 3, "sources": ["../../src/configuration/index.ts", "../../src/configuration/get-eslint-config.ts", "../../src/utils/utils.ts", "../../src/configuration/get-prettier-config.ts"], "sourcesContent": ["// JS Tool Configurations\nexport {getESLintConfig} from './get-eslint-config.js';\nexport {getPrettierConfig} from './get-prettier-config.js';\n", "import deepMerge from 'deepmerge';\nimport {ocularRoot} from '../utils/utils.js';\nimport {inspect} from 'util';\nimport {resolve} from 'path';\n\nconst localRules = (path) => resolve(ocularRoot, 'src/configuration', path);\n\nconst DEFAULT_OPTIONS = {\n react: false\n} as const;\n\nconst DEFAULT_CONFIG = {\n extends: [\n localRules('./eslint-config-uber-es2015/eslintrc.json'),\n 'prettier',\n 'plugin:import/recommended'\n ],\n plugins: ['import'],\n parserOptions: {\n ecmaVersion: 2020\n },\n env: {\n // Note: also sets ecmaVersion\n es2020: true\n },\n globals: {\n globalThis: 'readonly',\n __VERSION__: 'readonly'\n },\n rules: {\n 'guard-for-in': 'off',\n 'func-names': 'off',\n 'no-inline-comments': 'off',\n 'no-multi-str': 'off',\n // Rules disabled because they conflict with our preferred style\n // We use function hoisting to put exports at top of file\n 'no-use-before-define': 'off',\n camelcase: 'warn',\n // Let prettier handle this\n indent: 'off',\n 'accessor-pairs': ['error', {getWithoutSet: false, setWithoutGet: false}],\n 'import/no-extraneous-dependencies': ['error', {devDependencies: false, peerDependencies: true}]\n },\n settings: {\n // Ensure eslint finds typescript files\n 'import/resolver': {\n node: {\n extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.d.ts']\n }\n }\n },\n ignorePatterns: ['node_modules', '**/dist*/**/*.js'],\n overrides: [\n {\n // babel-eslint can process TS files, but it doesn't understand types\n // typescript-eslint has some more advanced rules with type checking\n files: ['**/*.ts', '**/*.tsx', '**/*.d.ts'],\n parser: '@typescript-eslint/parser',\n parserOptions: {\n sourceType: 'module', // we want to use ES modules\n project: './tsconfig.json'\n },\n extends: ['plugin:@typescript-eslint/recommended-type-checked'],\n plugins: ['@typescript-eslint'],\n rules: {\n '@typescript-eslint/no-dupe-class-members': 'error',\n '@typescript-eslint/switch-exhaustiveness-check': 'error',\n\n // This rule is incompatible with TypeScript, replace with the TS counterpart\n 'no-shadow': 'off',\n '@typescript-eslint/no-shadow': 'error',\n\n // Rules disabled because they conflict with our preferred style\n // We use function hoisting to put exports at top of file\n '@typescript-eslint/no-use-before-define': 'off',\n // We encourage explicit typing, e.g `field: string = ''`\n '@typescript-eslint/no-inferrable-types': 'off',\n // Allow noOp as default value for callbacks\n '@typescript-eslint/no-empty-function': 'off',\n\n // Rules downgraded because they are deemed acceptable\n '@typescript-eslint/ban-ts-comment': [\n 'error',\n {\n 'ts-expect-error': 'allow-with-description',\n 'ts-ignore': 'allow-with-description',\n 'ts-nocheck': 'allow-with-description',\n 'ts-check': false,\n minimumDescriptionLength: 3\n }\n ],\n '@typescript-eslint/no-floating-promises': 'warn',\n '@typescript-eslint/restrict-template-expressions': 'warn',\n '@typescript-eslint/no-empty-interface': 'warn',\n '@typescript-eslint/require-await': 'warn',\n\n // Rules that restrict the use of `any`\n // Might be too strict for our code base, but should be gradually enabled\n '@typescript-eslint/no-explicit-any': 'warn',\n '@typescript-eslint/no-unsafe-argument': 'warn',\n '@typescript-eslint/no-unsafe-assignment': 'warn',\n '@typescript-eslint/no-unsafe-call': 'warn',\n '@typescript-eslint/no-unsafe-enum-comparison': 'warn',\n '@typescript-eslint/no-unsafe-member-access': 'warn',\n '@typescript-eslint/no-unsafe-return': 'warn',\n '@typescript-eslint/explicit-module-boundary-types': 'warn'\n }\n },\n {\n // We can lint through code examples in Markdown as well,\n // but we don't need to enable all of the rules there\n files: ['**/*.md'],\n plugins: ['markdown'],\n // extends: 'plugin:markdown/recommended',\n rules: {\n 'no-undef': 'off',\n 'no-unused-vars': 'off',\n 'no-unused-expressions': 'off',\n 'no-console': 'off',\n 'padded-blocks': 'off'\n }\n }\n ]\n};\n\nfunction getReactConfig(options) {\n return {\n extends: [\n localRules('./eslint-config-uber-jsx/eslintrc.json'),\n 'prettier',\n 'plugin:import/recommended'\n ],\n plugins: ['import', 'react'],\n settings: {\n react: {\n version: options.react\n }\n }\n };\n}\n\nexport function getESLintConfig(\n options: {react?: string | false; overrides?: any; debug?: boolean} = {}\n) {\n options = {...DEFAULT_OPTIONS, ...options};\n\n let config = {...DEFAULT_CONFIG};\n if (options.react) {\n config = deepMerge(config, getReactConfig(options));\n }\n if (options.overrides) {\n config = deepMerge(config, options.overrides);\n }\n if (options.debug) {\n // eslint-disable-next-line\n console.log(inspect(config, {colors: true, depth: null}));\n }\n\n return config;\n}\n", "import fs from 'fs';\nimport {resolve, dirname} from 'path';\nimport {fileURLToPath} from 'node:url';\nimport {execSync} from 'child_process';\n\nexport function execShellCommand(command: string, args: string[] = []) {\n try {\n execSync(`${command} ${args.join(' ')}`, {\n stdio: 'inherit'\n });\n } catch (err: unknown) {\n process.exit((err as any).status);\n }\n}\n\n/** Returns the path to the root directory of ocular-dev-tools */\nexport const ocularRoot: string = (function () {\n let dir;\n try {\n dir = __dirname;\n } catch {\n dir = dirname(fileURLToPath(import.meta.url));\n }\n return resolve(dir, '../..');\n})();\n\nexport function shallowMerge<T>(base: T, override: any): T {\n for (const key in override) {\n if (base[key] && typeof base[key] === 'object') {\n Object.assign(base[key], override[key]);\n } else {\n base[key] = override[key];\n }\n }\n return base;\n}\n\n/** Given a list of paths, return the first one that exists */\nexport function getValidPath(...resolveOrder: string[]): string | null {\n for (const path of resolveOrder) {\n if (fs.existsSync(path)) {\n return path;\n }\n }\n return null;\n}\n", "import deepMerge from 'deepmerge';\n\nconst DEFAULT_CONFIG = {\n printWidth: 100,\n semi: true,\n singleQuote: true,\n trailingComma: 'none',\n bracketSpacing: false\n};\n\nexport function getPrettierConfig(options: {overrides?: any; debug?: boolean} = {}) {\n let config = {...DEFAULT_CONFIG};\n if (options.overrides) {\n config = deepMerge(config, options.overrides);\n }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