@nivalis/eslint-config
Version:
ESLint shareable flat config used at Nivalis Studio
1,083 lines (1,068 loc) • 31.9 kB
JavaScript
import { GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSX, GLOB_MARKDOWN, GLOB_REACT, GLOB_SRC, GLOB_SRC_EXT, GLOB_SRC_JS, GLOB_SRC_TS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_YAML } from "./globs-B8RQso9M.js";
import { DEFAULT_INDENT, PADDING_LINES } from "./constants-ZdZhr2ev.js";
import { FlatConfigComposer } from "eslint-flat-config-utils";
import pluginComments from "@eslint-community/eslint-plugin-eslint-comments";
import eslintPluginImportX from "eslint-plugin-import-x";
import globals from "globals";
import pluginJsdoc from "eslint-plugin-jsdoc";
import eslintPluginJsonc from "eslint-plugin-jsonc";
import nodePlugin from "eslint-plugin-n";
import { configs } from "eslint-plugin-regexp";
import pluginStylistic from "@stylistic/eslint-plugin";
import eslintPluginUnicorn from "eslint-plugin-unicorn";
import eslintPluginSonarjs from "eslint-plugin-sonarjs";
import { isPackageExists } from "local-pkg";
import pluginPromise from "eslint-plugin-promise";
//#region src/configs/comments.ts
const comments = () => {
return [{
name: "nivalis/eslint-comments/rules",
plugins: { "eslint-comments": pluginComments },
rules: {
"eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
"eslint-comments/no-aggregating-enable": "error",
"eslint-comments/no-duplicate-disable": "error",
"eslint-comments/no-unlimited-disable": "error",
"eslint-comments/no-unused-enable": "error"
}
}];
};
//#endregion
//#region src/configs/ignores.ts
const ignores = (userIgnores = []) => {
return [{
name: "nivalis/ignores",
ignores: [...GLOB_EXCLUDE, ...userIgnores]
}];
};
//#endregion
//#region src/configs/imports.ts
const imports = async (withTypescript = true) => {
const importsConfig = [{
name: "nivalis/import/recommended",
plugins: { import: eslintPluginImportX },
rules: {
"import/no-unresolved": "error",
"import/named": "error",
"import/namespace": "error",
"import/default": "error",
"import/export": "error",
"import/no-named-as-default": "warn",
"import/no-named-as-default-member": "warn",
"import/no-duplicates": "warn"
},
languageOptions: {
ecmaVersion: 2018,
sourceType: "module"
}
}];
if (withTypescript) {
const tsParser = await import("@typescript-eslint/parser");
/**
* This config:
* 1) adds `.jsx`, `.ts`, `.cts`, `.mts`, and `.tsx` as an extension
* 2) enables JSX/TSX parsing
*/
const typeScriptExtensions = [
".ts",
".tsx",
".cts",
".mts"
];
const allExtensions = [
...typeScriptExtensions,
".js",
".jsx",
".cjs",
".mjs"
];
importsConfig.push({
name: "nivalis/import/settings",
settings: {
"import/extensions": allExtensions,
"import/external-module-folders": ["node_modules", "node_modules/@types"],
"import/parsers": { "@typescript-eslint/parser": [...typeScriptExtensions] },
"import/resolver": { typescript: true }
},
rules: { "import/named": "off" }
}, {
name: "import/flat/options",
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
ignores: ["eslint.config.js"],
languageOptions: {
parser: tsParser,
ecmaVersion: "latest",
sourceType: "module"
},
rules: {
"no-unused-vars": "off",
"import/no-dynamic-require": "warn"
}
});
}
importsConfig.push({
name: "nivalis/import/rules",
rules: {
"import/named": "off",
"import/namespace": "off",
"import/default": "off",
"import/no-named-as-default-member": "off",
"import/no-unresolved": "off",
"import/no-deprecated": "off",
"import/no-named-as-default": "off",
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
"import/export": "error",
"import/first": "error",
"import/no-anonymous-default-export": ["error", {
allowAnonymousClass: false,
allowAnonymousFunction: false,
allowArray: false,
allowArrowFunction: false,
allowLiteral: false,
allowObject: false
}],
"import/no-default-export": "error",
"import/no-duplicates": "error",
"import/no-empty-named-blocks": "error",
"import/no-import-module-exports": ["error", { exceptions: [] }],
"import/no-mutable-exports": "error",
"import/no-named-default": "error",
"import/no-self-import": "error",
"import/no-webpack-loader-syntax": "error",
"import/order": ["error", {
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
"object",
"type"
],
pathGroups: [{
group: "internal",
pattern: "{{@,~}/,#}**"
}],
pathGroupsExcludedImportTypes: ["type"],
warnOnUnassignedImports: true
}]
}
}, {
name: "nivalis/import/disable",
files: [
`**/*config*.${GLOB_SRC_EXT}`,
`**/views/${GLOB_SRC}`,
`**/pages/${GLOB_SRC}`,
`**/app/${GLOB_SRC}`,
"**/{index,vite,esbuild,rollup,webpack,rspack}.ts",
"**/*.d.ts",
`${GLOB_MARKDOWN}/**`
],
rules: { "import/no-default-export": "off" }
});
return importsConfig;
};
//#endregion
//#region src/configs/javascript.ts
const MAX_COMPLEXITY = 25;
const MAX_LINES = 500;
const MAX_LINES_PER_FUNCTION = 250;
const MAX_NESTED_CALLBACKS = 4;
const MAX_PARAMS = 5;
const MAX_STATEMENTS = 35;
const javascript = () => {
return [{
name: "nivalis/javascript/setup",
languageOptions: {
globals: {
...globals.browser,
...globals.node
},
parserOptions: { ecmaVersion: 2022 }
}
}, {
name: "nivalis/javascript/rules",
files: [GLOB_SRC],
rules: {
"valid-typeof": "error",
"accessor-pairs": ["error", {
enforceForClassMembers: true,
getWithoutSet: false,
setWithoutGet: true
}],
"array-callback-return": ["error", {
allowImplicit: true,
checkForEach: false
}],
"block-scoped-var": "error",
camelcase: ["error", {
ignoreDestructuring: false,
ignoreGlobals: true,
ignoreImports: false,
properties: "never"
}],
"class-methods-use-this": ["error", {
enforceForClassFields: true,
exceptMethods: []
}],
complexity: ["error", MAX_COMPLEXITY],
"constructor-super": "error",
"default-case": ["error", { commentPattern: "(?:)" }],
"default-case-last": "error",
"default-param-last": "error",
"dot-notation": ["error", { allowKeywords: true }],
eqeqeq: ["error", "smart"],
"for-direction": ["error"],
"func-name-matching": [
"error",
"never",
{
considerPropertyDescriptor: true,
includeCommonJSModuleExports: false
}
],
"func-names": ["warn"],
"func-style": [
"error",
"expression",
{ allowArrowFunctions: true }
],
"getter-return": ["error", { allowImplicit: true }],
"grouped-accessor-pairs": ["error", "getBeforeSet"],
"id-denylist": ["error", "native"],
"id-length": ["error", {
exceptions: [
"_",
"i",
"j",
"k",
"x",
"y",
"z",
"a",
"b",
"c"
],
max: 30,
min: 2,
properties: "never"
}],
"max-lines": ["warn", {
max: MAX_LINES,
skipBlankLines: true,
skipComments: true
}],
"max-lines-per-function": ["warn", {
IIFEs: true,
max: MAX_LINES_PER_FUNCTION,
skipBlankLines: true,
skipComments: true
}],
"max-nested-callbacks": ["error", MAX_NESTED_CALLBACKS],
"max-params": ["error", MAX_PARAMS],
"max-statements": ["error", MAX_STATEMENTS],
"new-cap": ["warn", {
capIsNew: false,
newIsCap: true,
properties: true
}],
"no-alert": "error",
"no-array-constructor": "error",
"no-async-promise-executor": "error",
"no-await-in-loop": ["error"],
"no-caller": "error",
"no-case-declarations": "error",
"no-class-assign": ["error"],
"no-compare-neg-zero": "error",
"no-cond-assign": ["error", "always"],
"no-console": ["warn", { allow: ["warn", "error"] }],
"no-const-assign": "error",
"no-constant-binary-expression": "error",
"no-constant-condition": ["error", { checkLoops: false }],
"no-constructor-return": ["error"],
"no-control-regex": "error",
"no-debugger": ["warn"],
"no-delete-var": "error",
"no-div-regex": ["error"],
"no-dupe-args": "error",
"no-dupe-class-members": "error",
"no-dupe-else-if": ["error"],
"no-dupe-keys": "error",
"no-duplicate-case": ["error"],
"no-else-return": ["error", { allowElseIf: false }],
"no-empty": ["error"],
"no-empty-character-class": "error",
"no-empty-function": ["error", { allow: ["arrowFunctions", "functions"] }],
"no-empty-pattern": "error",
"no-empty-static-block": ["error"],
"no-eval": ["error"],
"no-ex-assign": ["error"],
"no-extend-native": ["error"],
"no-extra-bind": ["error"],
"no-extra-boolean-cast": ["error"],
"no-extra-label": ["error"],
"no-fallthrough": ["warn", { commentPattern: String.raw`break[\s\w]*omitted` }],
"no-func-assign": "error",
"no-global-assign": "error",
"no-implicit-coercion": ["error", {
allow: [],
boolean: false,
disallowTemplateShorthand: false,
number: true,
string: true
}],
"no-implicit-globals": ["error"],
"no-implied-eval": ["error"],
"no-import-assign": ["error"],
"no-inner-declarations": ["error", "functions"],
"no-invalid-regexp": ["error", { allowConstructorFlags: ["u", "y"] }],
"no-invalid-this": ["error"],
"no-irregular-whitespace": "error",
"no-iterator": ["error"],
"no-label-var": ["error"],
"no-labels": ["error", {
allowLoop: false,
allowSwitch: false
}],
"no-lone-blocks": "error",
"no-lonely-if": ["error"],
"no-loop-func": ["error"],
"no-loss-of-precision": ["error"],
"no-magic-numbers": ["warn", {
detectObjects: false,
enforceConst: true,
ignore: [
0,
1,
-1
],
ignoreArrayIndexes: true
}],
"no-misleading-character-class": "error",
"no-multi-str": "error",
"no-negated-condition": ["error"],
"no-new": "error",
"no-new-func": "error",
"no-new-native-nonconstructor": ["error"],
"no-new-wrappers": ["error"],
"no-nonoctal-decimal-escape": ["error"],
"no-obj-calls": ["error"],
"no-octal": ["error"],
"no-octal-escape": ["error"],
"no-param-reassign": ["error", {
ignorePropertyModificationsFor: [
"accumulator",
"ctx",
"context",
"req",
"request",
"res",
"response",
"$scope",
"staticContext"
],
ignorePropertyModificationsForRegex: [],
props: true
}],
"no-plusplus": ["error", { allowForLoopAfterthoughts: true }],
"no-promise-executor-return": ["error"],
"no-proto": ["error"],
"no-prototype-builtins": ["error"],
"no-redeclare": ["error", { builtinGlobals: false }],
"no-regex-spaces": ["error"],
"no-restricted-globals": [
"error",
{
message: "Use `globalThis` instead.",
name: "global"
},
{
message: "Use `globalThis` instead.",
name: "self"
},
{
message: "Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite",
name: "isFinite"
},
{
message: "Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan",
name: "isNaN"
}
],
"no-restricted-properties": [
"error",
{
message: "Symbol.for is unshimmable",
object: "Symbol",
property: "for"
},
{
message: "arguments.callee is deprecated",
object: "arguments",
property: "callee"
},
{
message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",
property: "__proto__"
},
{
message: "Use `Object.defineProperty` instead.",
property: "__defineGetter__"
},
{
message: "Use `Object.defineProperty` instead.",
property: "__defineSetter__"
},
{
message: "Use `Object.getOwnPropertyDescriptor` instead.",
property: "__lookupGetter__"
},
{
message: "Use `Object.getOwnPropertyDescriptor` instead.",
property: "__lookupSetter__"
},
{
message: "Use Number.isFinite instead",
object: "global",
property: "isFinite"
},
{
message: "Use Number.isFinite instead",
object: "self",
property: "isFinite"
},
{
message: "Use Number.isFinite instead",
object: "window",
property: "isFinite"
},
{
message: "Use Number.isNaN instead",
object: "global",
property: "isNaN"
},
{
message: "Use Number.isNaN instead",
object: "self",
property: "isNaN"
},
{
message: "Use Number.isNaN instead",
object: "window",
property: "isNaN"
}
],
"no-restricted-syntax": [
"error",
"DebuggerStatement",
"ForInStatement",
"LabeledStatement",
"WithStatement",
"TSEnumDeclaration[const=true]",
"TSExportAssignment",
{
message: "Import/export only modules you need",
selector: ":matches(ImportNamespaceSpecifier)"
},
{
message: "Avoid PropTypes. Use Typescript instead.",
selector: "Identifier[name='PropTypes']"
},
{
message: "Avoid PropTypes. Use Typescript instead.",
selector: "Identifier[name='propTypes']"
}
],
"no-return-assign": ["error", "always"],
"no-script-url": ["error"],
"no-self-assign": ["error", { props: true }],
"no-self-compare": "error",
"no-sequences": ["error", { allowInParentheses: false }],
"no-setter-return": ["error"],
"no-shadow": ["warn", {
allow: [
"resolve",
"reject",
"done",
"next",
"err",
"error",
"cb"
],
builtinGlobals: false,
hoist: "functions"
}],
"no-shadow-restricted-names": "error",
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-this-before-super": "error",
"no-throw-literal": "error",
"no-undef": "error",
"no-undef-init": "error",
"no-unexpected-multiline": ["error"],
"no-unmodified-loop-condition": ["error"],
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
"no-unreachable": "error",
"no-unreachable-loop": "error",
"no-unsafe-finally": "error",
"no-unsafe-negation": ["error", { enforceForOrderingRelations: true }],
"no-unsafe-optional-chaining": ["error", { disallowArithmeticOperators: true }],
"no-unused-expressions": ["error", {
allowShortCircuit: true,
allowTaggedTemplates: true,
allowTernary: true,
enforceForJSX: true
}],
"no-unused-labels": ["error"],
"no-unused-private-class-members": ["error"],
"no-unused-vars": ["error", {
args: "none",
caughtErrors: "none",
ignoreRestSiblings: true,
vars: "all"
}],
"no-use-before-define": ["error", {
allowNamedExports: false,
classes: false,
functions: false,
variables: true
}],
"no-useless-backreference": "error",
"no-useless-call": "error",
"no-useless-catch": "error",
"no-useless-computed-key": ["error", { enforceForClassMembers: true }],
"no-useless-concat": ["error"],
"no-useless-constructor": ["error"],
"no-useless-escape": ["error"],
"no-useless-rename": ["error", {
ignoreDestructuring: false,
ignoreExport: false,
ignoreImport: false
}],
"no-useless-return": ["error"],
"no-var": ["error"],
"no-void": ["error"],
"no-warning-comments": ["warn", { terms: ["fixme", "todo"] }],
"no-with": "error",
"object-shorthand": [
"error",
"always",
{
avoidQuotes: true,
ignoreConstructors: false
}
],
"one-var": ["error", { initialized: "never" }],
"prefer-arrow-callback": ["error", {
allowNamedFunctions: false,
allowUnboundThis: true
}],
"prefer-const": ["warn", {
destructuring: "all",
ignoreReadBeforeAssign: true
}],
"prefer-exponentiation-operator": "error",
"prefer-promise-reject-errors": ["error", { allowEmptyReject: true }],
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
radix: ["error"],
"require-atomic-updates": ["error", { allowProperties: true }],
"require-await": ["error"],
"require-yield": ["error"],
"sort-imports": ["error", {
allowSeparatedGroups: false,
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: [
"none",
"all",
"multiple",
"single"
]
}],
strict: ["error", "safe"],
"symbol-description": ["error"],
"unicode-bom": ["error", "never"],
"use-isnan": ["error", {
enforceForIndexOf: true,
enforceForSwitchCase: true
}],
"vars-on-top": "error",
yoda: [
"error",
"never",
{
exceptRange: true,
onlyEquality: false
}
],
"arrow-body-style": "error",
"capitalized-comments": "off",
"consistent-return": "off",
"consistent-this": "error",
curly: "error",
"guard-for-in": "error",
"id-match": "error",
"init-declarations": "off",
"logical-assignment-operators": "error",
"max-classes-per-file": "error",
"max-depth": "error",
"no-bitwise": "error",
"no-continue": "off",
"no-duplicate-imports": "error",
"no-eq-null": "error",
"no-inline-comments": "off",
"no-multi-assign": "error",
"no-nested-ternary": "error",
"no-object-constructor": "error",
"no-restricted-exports": "error",
"no-restricted-imports": "error",
"no-undefined": "error",
"no-underscore-dangle": "off",
"no-useless-assignment": "off",
"operator-assignment": "error",
"prefer-destructuring": "off",
"prefer-named-capture-group": "off",
"prefer-numeric-literals": "error",
"prefer-object-has-own": "error",
"prefer-object-spread": "error",
"require-unicode-regexp": "off",
"sort-vars": "error"
}
}];
};
//#endregion
//#region src/configs/jsdoc.ts
const jsdoc = () => {
return [{
...pluginJsdoc.configs["flat/recommended"],
name: "nivalis/jsdoc/recommended"
}, {
name: "nivalis/jsdoc/rules",
rules: {
"jsdoc/check-access": "warn",
"jsdoc/check-param-names": "warn",
"jsdoc/check-property-names": "warn",
"jsdoc/check-types": "warn",
"jsdoc/empty-tags": "warn",
"jsdoc/implements-on-classes": "warn",
"jsdoc/no-defaults": "warn",
"jsdoc/no-multi-asterisks": "warn",
"jsdoc/require-param-name": "warn",
"jsdoc/require-property": "warn",
"jsdoc/require-property-description": "warn",
"jsdoc/require-property-name": "warn",
"jsdoc/require-returns-check": "warn",
"jsdoc/require-returns-description": "warn",
"jsdoc/require-yields-check": "warn",
"jsdoc/multiline-blocks": "off",
"jsdoc/check-alignment": "off",
"jsdoc/require-jsdoc": "off"
}
}];
};
//#endregion
//#region src/configs/jsonc.ts
const jsonc = () => eslintPluginJsonc.configs["flat/recommended-with-json"].map((config) => ({
...config,
name: "nivalis/jsonc/recommended"
}));
//#endregion
//#region src/configs/node.ts
const node = () => [{
name: "nivalis/node/config",
plugins: { node: nodePlugin }
}, {
files: [GLOB_SRC],
name: "nivalis/node/rules",
rules: {
"node/no-deprecated-api": "error",
"node/no-extraneous-import": "error",
"node/no-extraneous-require": "error",
"node/no-exports-assign": "error",
"node/no-missing-require": "error",
"node/no-process-exit": "error",
"node/no-unpublished-bin": "error",
"node/no-unpublished-import": "error",
"node/no-unpublished-require": "error",
"node/no-unsupported-features/es-builtins": "error",
"node/no-unsupported-features/node-builtins": ["error", { ignores: ["fetch", "navigator"] }],
"node/process-exit-as-throw": "error",
"node/hashbang": "error",
"node/no-unsupported-features/es-syntax": ["error", { ignores: ["modules"] }],
"node/no-missing-import": "off"
}
}];
//#endregion
//#region src/configs/regexp.ts
const regexp = () => {
return [{
...configs["flat/recommended"],
name: "nivalis/regexp/setup"
}, {
name: "nivalis/regexp/rules",
rules: { "regexp/letter-case": ["error", {
caseInsensitive: "lowercase",
unicodeEscape: "uppercase"
}] }
}];
};
//#endregion
//#region src/configs/stylistic.ts
const options = {
indent: DEFAULT_INDENT,
jsx: true,
quotes: "single",
semi: true
};
const stylistic = () => {
const { indent, jsx, quotes, semi } = options;
const config = pluginStylistic.configs.customize({
arrowParens: false,
blockSpacing: true,
braceStyle: "1tbs",
indent,
jsx,
pluginName: "style",
quoteProps: "as-needed",
quotes,
semi
});
return [
{
name: "nivalis/stylistic/plugin",
plugins: { style: pluginStylistic }
},
{
files: [GLOB_SRC],
name: "nivalis/stylistic/rules",
rules: {
...config.rules,
curly: [
"error",
"multi-line",
"consistent"
],
"style/jsx-curly-brace-presence": ["error", {
children: "ignore",
propElementValues: "always",
props: "never"
}],
"style/jsx-pascal-case": ["error", {
allowAllCaps: true,
ignore: []
}],
"style/jsx-sort-props": ["error", {
callbacksLast: true,
ignoreCase: true,
locale: "auto",
multiline: "last",
noSortAlphabetically: true,
reservedFirst: true,
shorthandFirst: true,
shorthandLast: false
}],
"style/multiline-comment-style": ["warn", "bare-block"],
"style/no-multiple-empty-lines": ["error", {
max: 1,
maxBOF: 0,
maxEOF: 0
}],
"style/padding-line-between-statements": ["error", ...PADDING_LINES],
"style/quote-props": ["error", "as-needed"],
"style/quotes": [
"error",
options.quotes,
{
avoidEscape: true,
allowTemplateLiterals: false
}
],
"style/operator-linebreak": [
"error",
"after",
{ overrides: {
"?": "before",
":": "before"
} }
],
"style/indent-binary-ops": ["off"]
}
},
{
files: [GLOB_SRC],
name: "nivalis/stylistic/disable",
rules: {
"style/array-bracket-newline": "off",
"style/array-bracket-spacing": "off",
"style/array-element-newline": "off",
"style/arrow-parens": "off",
"style/arrow-spacing": "off",
"style/babel/object-curly-spacing": "off",
"style/babel/quotes": "off",
"style/babel/semi": "off",
"style/block-spacing": "off",
"style/brace-style": "off",
"style/comma-dangle": "off",
"style/comma-spacing": "off",
"style/comma-style": "off",
"style/computed-property-spacing": "off",
"style/curly": "off",
"style/dot-location": "off",
"style/eol-last": "off",
"style/func-call-spacing": "off",
"style/function-call-argument-newline": "off",
"style/function-paren-newline": "off",
"style/generator-star-spacing": "off",
"style/implicit-arrow-linebreak": "off",
"style/indent": "off",
"style/jsx-child-element-spacing": "off",
"style/jsx-closing-bracket-location": "off",
"style/jsx-closing-tag-location": "off",
"style/jsx-curly-newline": "off",
"style/jsx-curly-spacing": "off",
"style/jsx-equals-spacing": "off",
"style/jsx-first-prop-new-line": "off",
"style/jsx-indent": "off",
"style/jsx-indent-props": "off",
"style/jsx-max-props-per-line": "off",
"style/jsx-newline": "off",
"style/jsx-one-expression-per-line": "off",
"style/jsx-props-no-multi-spaces": "off",
"style/jsx-quotes": "off",
"style/jsx-tag-spacing": "off",
"style/jsx-wrap-multilines": "off",
"style/key-spacing": "off",
"style/keyword-spacing": "off",
"style/linebreak-style": "off",
"style/lines-around-comment": "off",
"style/max-len": "off",
"style/max-statements-per-line": "off",
"style/member-delimiter-style": "off",
"style/multiline-comment-style": "off",
"style/multiline-ternary": "off",
"style/new-parens": "off",
"style/newline-per-chained-call": "off",
"style/no-confusing-arrow": "off",
"style/no-extra-parens": "off",
"style/no-extra-semi": "off",
"style/no-floating-decimal": "off",
"style/no-mixed-operators": "off",
"style/no-mixed-spaces-and-tabs": "off",
"style/no-multi-spaces": "off",
"style/no-multiple-empty-lines": "off",
"style/no-tabs": "off",
"style/no-trailing-spaces": "off",
"style/no-unexpected-multiline": "off",
"style/no-whitespace-before-property": "off",
"style/nonblock-statement-body-position": "off",
"style/object-curly-newline": "off",
"style/object-curly-spacing": "off",
"style/object-property-newline": "off",
"style/one-var-declaration-per-line": "off",
"style/operator-linebreak": "off",
"style/padded-blocks": "off",
"style/quote-props": "off",
"style/quotes": "off",
"style/rest-spread-spacing": "off",
"style/semi": "off",
"style/semi-spacing": "off",
"style/semi-style": "off",
"style/space-before-blocks": "off",
"style/space-before-function-paren": "off",
"style/space-in-parens": "off",
"style/space-infix-ops": "off",
"style/space-unary-ops": "off",
"style/standard/array-bracket-even-spacing": "off",
"style/standard/computed-property-even-spacing": "off",
"style/standard/object-curly-even-spacing": "off",
"style/switch-colon-spacing": "off",
"style/template-curly-spacing": "off",
"style/template-tag-spacing": "off",
"style/type-annotation-spacing": "off",
"style/wrap-iife": "off",
"style/wrap-regex": "off",
"style/yield-star-spacing": "off"
}
}
];
};
//#endregion
//#region src/configs/unicorn.ts
const unicorn = () => {
return [{
...eslintPluginUnicorn.configs.recommended,
name: "nivalis/unicorn/recommended"
}, {
name: "nivalis/unicorn/rules",
rules: {
"unicorn/filename-case": ["warn", {
cases: {
kebabCase: true,
pascalCase: true
},
ignore: [/^[A-Z]+\..*$/]
}],
"unicorn/prefer-global-this": "off",
"unicorn/prefer-string-raw": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/no-array-callback-reference": "warn",
"unicorn/no-null": "off",
"unicorn/no-array-reduce": "off",
"unicorn/no-abusive-eslint-disable": "off",
"unicorn/prefer-ternary": "off",
"unicorn/string-content": ["error", { patterns: { "(?!(?=.*(0.0.0.0|127.0.0.1|localhost|www.w3.org)))^http:": {
message: "Please use `https` for better security.`.",
suggest: "https:"
} } }]
}
}];
};
//#endregion
//#region src/configs/sonarjs.ts
const sonarjs = (options$1) => {
const config = [{
...eslintPluginSonarjs.configs.recommended,
name: "nivalis/sonarjs/recommended"
}, {
name: "nivalis/sonarjs/rules",
rules: {
"sonarjs/todo-tag": "off",
"sonarjs/fixme-tag": "off",
"sonarjs/no-unused-vars": "off",
"sonarjs/no-commented-code": "off",
"sonarjs/max-lines": "off",
"sonarjs/different-types-comparison": "off",
"sonarjs/deprecation": "off",
"sonarjs/no-redundant-optional": "off"
}
}];
if (options$1 && options$1.disableTypeChecking === true) config.push({
name: "nivalis/sonarjs/disables/type-checking",
rules: {
"sonarjs/anchor-precedence": "off",
"sonarjs/argument-type": "off",
"sonarjs/arguments-order": "off",
"sonarjs/class-prototype": "off",
"sonarjs/concise-regex": "off",
"sonarjs/deprecation": "off",
"sonarjs/different-types-comparison": "off",
"sonarjs/disabled-auto-escaping": "off",
"sonarjs/disabled-resource-integrity": "off",
"sonarjs/duplicates-in-character-class": "off",
"sonarjs/empty-string-repetition": "off",
"sonarjs/existing-groups": "off",
"sonarjs/function-return-type": "off",
"sonarjs/in-operator-type-error": "off",
"sonarjs/index-of-compare-to-positive-number": "off",
"sonarjs/jsx-no-leaked-render": "off",
"sonarjs/new-operator-misuse": "off",
"sonarjs/no-alphabetical-sort": "off",
"sonarjs/no-array-delete": "off",
"sonarjs/no-associative-arrays": "off",
"sonarjs/no-collection-size-mischeck": "off",
"sonarjs/no-control-regex": "off",
"sonarjs/no-empty-after-reluctant": "off",
"sonarjs/no-empty-alternatives": "off",
"sonarjs/no-empty-character-class": "off",
"sonarjs/no-empty-group": "off",
"sonarjs/no-for-in-iterable": "off",
"sonarjs/no-ignored-return": "off",
"sonarjs/no-in-misuse": "off",
"sonarjs/no-incorrect-string-concat": "off",
"sonarjs/no-invalid-await": "off",
"sonarjs/no-invalid-regexp": "off",
"sonarjs/no-misleading-array-reverse": "off",
"sonarjs/no-misleading-character-class": "off",
"sonarjs/no-redundant-optional": "off",
"sonarjs/no-regex-spaces": "off",
"sonarjs/no-require-or-define": "off",
"sonarjs/no-return-type-any": "off",
"sonarjs/no-selector-parameter": "off",
"sonarjs/no-try-promise": "off",
"sonarjs/no-undefined-argument": "off",
"sonarjs/no-useless-intersection": "off",
"sonarjs/non-number-in-arithmetic-expression": "off",
"sonarjs/operation-returning-nan": "off",
"sonarjs/post-message": "off",
"sonarjs/prefer-read-only-props": "off",
"sonarjs/prefer-regexp-exec": "off",
"sonarjs/reduce-initial-value": "off",
"sonarjs/regex-complexity": "off",
"sonarjs/single-char-in-character-classes": "off",
"sonarjs/single-character-alternation": "off",
"sonarjs/slow-regex": "off",
"sonarjs/strings-comparison": "off",
"sonarjs/unicode-aware-regex": "off",
"sonarjs/unused-import": "off",
"sonarjs/unused-named-groups": "off",
"sonarjs/useless-string-operation": "off",
"sonarjs/values-not-convertible-to-numbers": "off",
"sonarjs/void-use": "off",
"sonarjs/web-sql-database": "off"
}
});
config.push({
name: "nivalis/sonarjs/react",
files: [GLOB_REACT],
rules: { "sonarjs/function-return-type": "off" }
});
return config;
};
//#endregion
//#region src/environment.ts
const HAS_TYPESCRIPT = isPackageExists("typescript");
const HAS_REACT = isPackageExists("react");
const HAS_NEXTJS = isPackageExists("next");
const HAS_TAILWINDCSS = isPackageExists("tailwindcss");
//#endregion
//#region src/configs/promise.ts
const promise = () => {
return [{
...pluginPromise.configs["flat/recommended"],
name: "nivalis/promise/setup"
}, {
name: "nivalis/promise/rules",
rules: {
"promise/always-return": ["error", { ignoreLastCallback: true }],
"promise/no-multiple-resolved": "warn"
}
}];
};
//#endregion
//#region src/factory.ts
const nivalis = async (options$1, ...userConfigs) => {
const enableNextJs = HAS_NEXTJS && options$1?.nextjs !== false || options$1?.nextjs === true;
const enableReact = HAS_REACT && options$1?.react !== false || options$1?.react === true;
const enableTailwindCss = HAS_TAILWINDCSS && options$1?.tailwindcss !== false;
const enableTypescript = HAS_TYPESCRIPT && options$1?.typescript !== false;
let composer = new FlatConfigComposer(ignores(options$1?.ignores), await imports(!enableTypescript), javascript(), stylistic(), jsdoc(), jsonc(), regexp(), node(), promise(), comments(), unicorn(), sonarjs(options$1?.typescript));
if (enableReact) {
const mod = await import("./react-lgnrUqgP.js");
composer = composer.append(...mod.react());
}
if (enableNextJs) {
const mod = await import("./nextjs-C7vPGvEI.js");
composer = composer.append(...mod.nextjs());
}
if (enableTailwindCss) {
const mod = await import("./tailwindcss-Dyoxz-EP.js");
composer = composer.append(...mod.tailwindcss(options$1?.tailwindcss));
}
if (enableTypescript) {
const mod = await import("./typescript-CnkaZjHJ.js");
composer = composer.append(...mod.typescript(options$1?.typescript));
}
if (options$1?.prettier !== false) {
const mod = await import("./prettier-eOhtklOb.js");
composer = composer.append(...mod.prettier(options$1?.prettier));
}
composer = composer.append(...userConfigs);
return await composer;
};
//#endregion
export { GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSX, GLOB_MARKDOWN, GLOB_REACT, GLOB_SRC, GLOB_SRC_EXT, GLOB_SRC_JS, GLOB_SRC_TS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_YAML, nivalis };