UNPKG

@vis.gl/dev-tools

Version:

Dev tools for vis.gl frameworks

223 lines (217 loc) 7.76 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // dist/configuration/index.js var configuration_exports = {}; __export(configuration_exports, { getESLintConfig: () => getESLintConfig, getPrettierConfig: () => getPrettierConfig }); module.exports = __toCommonJS(configuration_exports); // dist/configuration/get-eslint-config.js var import_deepmerge = __toESM(require("deepmerge"), 1); // dist/utils/utils.js var import_fs = __toESM(require("fs"), 1); var import_path = require("path"); var import_node_url = require("node:url"); var import_child_process = require("child_process"); var import_meta = {}; var ocularRoot = function() { let dir; try { dir = __dirname; } catch { dir = (0, import_path.dirname)((0, import_node_url.fileURLToPath)(import_meta.url)); } return (0, import_path.resolve)(dir, "../.."); }(); // dist/configuration/get-eslint-config.js var import_util = require("util"); var import_path2 = require("path"); var localRules = (path) => (0, import_path2.resolve)(ocularRoot, "src/configuration", path); var DEFAULT_OPTIONS = { react: false }; var DEFAULT_CONFIG = { extends: [ localRules("./eslint-config-uber-es2015/eslintrc.json"), "prettier", "plugin:import/recommended" ], plugins: ["import"], parserOptions: { ecmaVersion: 2020 }, env: { // Note: also sets ecmaVersion es2020: true }, globals: { globalThis: "readonly", __VERSION__: "readonly" }, rules: { "guard-for-in": "off", "func-names": "off", "no-inline-comments": "off", "no-multi-str": "off", // Rules disabled because they conflict with our preferred style // We use function hoisting to put exports at top of file "no-use-before-define": "off", camelcase: "warn", // Let prettier handle this indent: "off", "accessor-pairs": ["error", { getWithoutSet: false, setWithoutGet: false }], "import/no-extraneous-dependencies": ["error", { devDependencies: false, peerDependencies: true }] }, settings: { // Ensure eslint finds typescript files "import/resolver": { node: { extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"] } } }, ignorePatterns: ["node_modules", "**/dist*/**/*.js"], overrides: [ { // babel-eslint can process TS files, but it doesn't understand types // typescript-eslint has some more advanced rules with type checking files: ["**/*.ts", "**/*.tsx", "**/*.d.ts"], parser: "@typescript-eslint/parser", parserOptions: { sourceType: "module", project: "./tsconfig.json" }, extends: ["plugin:@typescript-eslint/recommended-type-checked"], plugins: ["@typescript-eslint"], rules: { "@typescript-eslint/no-dupe-class-members": "error", "@typescript-eslint/switch-exhaustiveness-check": "error", // This rule is incompatible with TypeScript, replace with the TS counterpart "no-shadow": "off", "@typescript-eslint/no-shadow": "error", // Rules disabled because they conflict with our preferred style // We use function hoisting to put exports at top of file "@typescript-eslint/no-use-before-define": "off", // We encourage explicit typing, e.g `field: string = ''` "@typescript-eslint/no-inferrable-types": "off", // Allow noOp as default value for callbacks "@typescript-eslint/no-empty-function": "off", // Rules downgraded because they are deemed acceptable "@typescript-eslint/ban-ts-comment": [ "error", { "ts-expect-error": "allow-with-description", "ts-ignore": "allow-with-description", "ts-nocheck": "allow-with-description", "ts-check": false, minimumDescriptionLength: 3 } ], "@typescript-eslint/no-floating-promises": "warn", "@typescript-eslint/restrict-template-expressions": "warn", "@typescript-eslint/no-empty-interface": "warn", "@typescript-eslint/require-await": "warn", // Rules that restrict the use of `any` // Might be too strict for our code base, but should be gradually enabled "@typescript-eslint/no-explicit-any": "warn", "@typescript-eslint/no-unsafe-argument": "warn", "@typescript-eslint/no-unsafe-assignment": "warn", "@typescript-eslint/no-unsafe-call": "warn", "@typescript-eslint/no-unsafe-enum-comparison": "warn", "@typescript-eslint/no-unsafe-member-access": "warn", "@typescript-eslint/no-unsafe-return": "warn", "@typescript-eslint/explicit-module-boundary-types": "warn" } }, { // We can lint through code examples in Markdown as well, // but we don't need to enable all of the rules there files: ["**/*.md"], plugins: ["markdown"], // extends: 'plugin:markdown/recommended', rules: { "no-undef": "off", "no-unused-vars": "off", "no-unused-expressions": "off", "no-console": "off", "padded-blocks": "off" } } ] }; function getReactConfig(options) { return { extends: [ localRules("./eslint-config-uber-jsx/eslintrc.json"), "prettier", "plugin:import/recommended" ], plugins: ["import", "react"], settings: { react: { version: options.react } } }; } function getESLintConfig(options = {}) { options = { ...DEFAULT_OPTIONS, ...options }; let config = { ...DEFAULT_CONFIG }; if (options.react) { config = (0, import_deepmerge.default)(config, getReactConfig(options)); } if (options.overrides) { config = (0, import_deepmerge.default)(config, options.overrides); } if (options.debug) { console.log((0, import_util.inspect)(config, { colors: true, depth: null })); } return config; } // dist/configuration/get-prettier-config.js var import_deepmerge2 = __toESM(require("deepmerge"), 1); var DEFAULT_CONFIG2 = { printWidth: 100, semi: true, singleQuote: true, trailingComma: "none", bracketSpacing: false }; function getPrettierConfig(options = {}) { let config = { ...DEFAULT_CONFIG2 }; if (options.overrides) { config = (0, import_deepmerge2.default)(config, options.overrides); } if (options.debug) { console.log(config); } return config; } //# sourceMappingURL=index.cjs.map