Skip to content

Commit

Permalink
fix(eslint-config): build script
Browse files Browse the repository at this point in the history
  • Loading branch information
0x706b committed Jul 5, 2024
1 parent ebad5d6 commit 0aa58bb
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 91 deletions.
90 changes: 2 additions & 88 deletions packages/eslint-config/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,89 +1,3 @@
import { FlatCompat } from "@eslint/eslintrc";
import eslint from "@eslint/js";
import { legacyPlugin } from "@fncts/eslint-config/legacyPlugin";
import path from "node:path";
import { fileURLToPath } from "node:url";
import tseslint from "typescript-eslint";
import baseConfig from "@fncts/eslint-config";

const dirname = path.dirname(fileURLToPath(import.meta.url));

const compat = new FlatCompat({
baseDirectory: dirname,
recommendedConfig: eslint.configs.recommended,
});

export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.recommended, {
plugins: {
import: legacyPlugin(compat, "eslint-plugin-import", "import"),
"simple-import-sort": legacyPlugin(compat, "eslint-plugin-simple-import-sort", "simple-import-sort"),
codegen: legacyPlugin(compat, "eslint-plugin-codegen", "codegen"),
"@0x706b/align-assignments": legacyPlugin(
compat,
"@0x706b/eslint-plugin-align-assignments",
"@0x706b/align-assignments",
),
"@0x706b/module-specifier-extensions": legacyPlugin(
compat,
"@0x706b/eslint-plugin-module-specifier-extensions",
"@0x706b/module-specifier-extensions",
),
},
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
typescript: {
alwaysTryTypes: true,
project: `${dirname}/../config/tsconfig.base.json`,
},
},
},
rules: {
"@0x706b/align-assignments/align-assignments": "error",
"@0x706b/module-specifier-extensions/module-specifier-extensions": [
"error",
{
remove: ["^@fncts.*$"],
},
],
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-this-alias": "off",
quotes: ["warn", "double", { avoidEscape: true }],
"@typescript-eslint/semi": ["warn", "always"],
"simple-import-sort/exports": "warn",
"simple-import-sort/imports": [
"warn",
{
groups: [["^.*\\u0000$"], ["^\\u0000"], ["^@?\\w"], ["^"], ["^\\."]],
},
],
"codegen/codegen": [
"error",
{
presets: {
pipeable: "@fncts/codegen/pipeable",
barrel: "@fncts/codegen/barrel",
"type-barrel": "@fncts/codegen/type-barrel",
},
},
],
"import/order": "off",
"import/no-unresolved": "error",

"no-case-declarations": "off",
"no-empty": "off",
"no-unexpected-multiline": "off",
"no-fallthrough": "off",
"no-control-regex": "off",
"no-prototype-builtins": "off",
},
});
export default baseConfig;
89 changes: 89 additions & 0 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { FlatCompat } from "@eslint/eslintrc";
import eslint from "@eslint/js";
import { legacyPlugin } from "@fncts/eslint-config/legacyPlugin";
import path from "node:path";
import { fileURLToPath } from "node:url";
import tseslint from "typescript-eslint";

const dirname = path.dirname(fileURLToPath(import.meta.url));

const compat = new FlatCompat({
baseDirectory: dirname,
recommendedConfig: eslint.configs.recommended,
});

export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.recommended, {
plugins: {
import: legacyPlugin(compat, "eslint-plugin-import", "import"),
"simple-import-sort": legacyPlugin(compat, "eslint-plugin-simple-import-sort", "simple-import-sort"),
codegen: legacyPlugin(compat, "eslint-plugin-codegen", "codegen"),
"@0x706b/align-assignments": legacyPlugin(
compat,
"@0x706b/eslint-plugin-align-assignments",
"@0x706b/align-assignments",
),
"@0x706b/module-specifier-extensions": legacyPlugin(
compat,
"@0x706b/eslint-plugin-module-specifier-extensions",
"@0x706b/module-specifier-extensions",
),
},
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
typescript: {
alwaysTryTypes: true,
project: `${dirname}/../config/tsconfig.base.json`,
},
},
},
rules: {
"@0x706b/align-assignments/align-assignments": "error",
"@0x706b/module-specifier-extensions/module-specifier-extensions": [
"error",
{
remove: ["^@fncts.*$"],
},
],
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-this-alias": "off",
quotes: ["warn", "double", { avoidEscape: true }],
"@typescript-eslint/semi": ["warn", "always"],
"simple-import-sort/exports": "warn",
"simple-import-sort/imports": [
"warn",
{
groups: [["^.*\\u0000$"], ["^\\u0000"], ["^@?\\w"], ["^"], ["^\\."]],
},
],
"codegen/codegen": [
"error",
{
presets: {
pipeable: "@fncts/codegen/pipeable",
barrel: "@fncts/codegen/barrel",
"type-barrel": "@fncts/codegen/type-barrel",
},
},
],
"import/order": "off",
"import/no-unresolved": "error",

"no-case-declarations": "off",
"no-empty": "off",
"no-unexpected-multiline": "off",
"no-fallthrough": "off",
"no-control-regex": "off",
"no-prototype-builtins": "off",
},
});
6 changes: 3 additions & 3 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.0.19",
"type": "module",
"scripts": {
"build": "rm -rf build && mkdir build && mkdir build/cjs && cp index.cjs build/cjs/index.cjs",
"build-pack": "yarn build && yarn fncts-pack cjs"
"build": "rm -rf build && mkdir build && mkdir build/mjs && cp eslint.config.js build/mjs/eslint.config.mjs && cp legacyPlugin.js build/mjs/legacyPlugin.mjs",
"build-pack": "yarn build && yarn fncts-pack mjs"
},
"dependencies": {
"@0x706b/eslint-plugin-align-assignments": "^0.1.2",
Expand All @@ -31,7 +31,7 @@
},
"exports": {
".": {
"import": "./eslint.config.js"
"import": "./index.js"
},
"./*": {
"import": "./*.js"
Expand Down

0 comments on commit 0aa58bb

Please sign in to comment.