Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

28 changes: 0 additions & 28 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ dist

# TernJS port file
.tern-port

# OS junk
.DS_Store
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ Agile Digital's standard ESLint config

```sh
yarn add --dev @agiledigital/eslint-config \
eslint-config-typed-fp \
@typescript-eslint/eslint-plugin \
@typescript-eslint/parser \
@eslint/compat \
@eslint/eslintrc \
typescript-eslint \
eslint \
eslint-plugin-functional \
eslint-plugin-total-functions \
eslint-plugin-jest \
eslint-plugin-prettier \
eslint-plugin-sonarjs \
eslint-plugin-import \
eslint-plugin-import-x \
eslint-plugin-simple-import-sort \
eslint-plugin-filename-rules \
eslint-plugin-jsdoc \
Expand Down
23 changes: 0 additions & 23 deletions base-react.js

This file was deleted.

12 changes: 12 additions & 0 deletions base-react.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// FIXME why is this rule triggered here?
// eslint-disable-next-line import-x/no-unresolved
import tseslint from "typescript-eslint";
import base from "./index.mjs";
import react from "./react.mjs";
// This lint config is used for test the combination of base and react config.
// It only extends settings from base and react eslint config.
// eslint-disable-next-line functional/prefer-immutable-types
const config = tseslint.config({
extends: [...base, ...react],
});
export default config;
15 changes: 15 additions & 0 deletions base-react.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// FIXME why is this rule triggered here?
// eslint-disable-next-line import-x/no-unresolved
import tseslint from "typescript-eslint";
import base from "./index.mjs";
import react from "./react.mjs";

// This lint config is used for test the combination of base and react config.
// It only extends settings from base and react eslint config.

// eslint-disable-next-line functional/prefer-immutable-types
const config = tseslint.config({
extends: [...base, ...react],
});

export default config;
26 changes: 0 additions & 26 deletions base-react.ts

This file was deleted.

107 changes: 107 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// FIXME: disable this rule for all js and mjs files - we still need type annotations there (because not TypeScript)
/* eslint-disable jsdoc/no-types */
import url from "node:url";
import { fixupPluginRules } from "@eslint/compat";
import { FlatCompat } from "@eslint/eslintrc";
import eslintJs from "@eslint/js";
// FIXME why is this rule triggered here?
// eslint-disable-next-line import-x/no-unresolved
import tseslint from "typescript-eslint";
// FIXME why is this rule triggered here?
// eslint-disable-next-line import-x/no-unresolved
import functionalPlugin from "eslint-plugin-functional/flat";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import jsdoc from "eslint-plugin-jsdoc";
// @ts-expect-error FIXME eslint-plugin-jest needs type definitions
import jest from "eslint-plugin-jest";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import sonarjs from "eslint-plugin-sonarjs";
// @ts-expect-error FIXME eslint-plugin-jest needs type definitions
import noSecrets from "eslint-plugin-no-secrets";
import importX from "eslint-plugin-import-x";

// FIXME why is this rule triggered here?
// eslint-disable-next-line no-undef
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
// eslint-disable-next-line functional/prefer-immutable-types
const compat = new FlatCompat({ baseDirectory: __dirname });

/**
* @param {string} name the plugin name
* @param {string} alias the plugin alias
* @returns {import("eslint").ESLint.Plugin} the plugin
* @see https://github.com/import-js/eslint-plugin-import/issues/2948#issuecomment-2148832701
*/
// eslint-disable-next-line functional/prefer-immutable-types
const legacyPlugin = (name, alias = name) => {
// eslint-disable-next-line functional/prefer-immutable-types
const plugin = compat.plugins(name)[0]?.plugins?.[alias];

// eslint-disable-next-line functional/no-conditional-statements
if (plugin === undefined) {
// eslint-disable-next-line functional/no-throw-statements
throw new Error(
`Unable to resolve plugin [${name}] and/or alias [${alias}].`,
);
}

return fixupPluginRules(plugin);
};

// See https://typescript-eslint.io/getting-started
// See https://typescript-eslint.io/packages/typescript-eslint/#config
export default tseslint.config(
eslintJs.configs.recommended,
tseslint.configs.eslintRecommended,
...tseslint.configs.strictTypeChecked,
functionalPlugin.configs.strict,
jsdoc.configs["flat/recommended-typescript"],
// FIXME eslint-plugin-jest needs type definitions
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
jest.configs["flat/recommended"],
sonarjs.configs.recommended,
...compat.extends(
"plugin:import-x/recommended",
"plugin:import-x/typescript",
),
// This must come last. See https://github.com/prettier/eslint-plugin-prettier
eslintPluginPrettierRecommended,
{
linterOptions: {
reportUnusedDisableDirectives: true,
},
languageOptions: {
globals: {
"jest/globals": true,
es6: true,
},
// See https://typescript-eslint.io/getting-started/typed-linting
parserOptions: {
project: "tsconfig.json",
tsconfigRootDir: __dirname,
},
},
plugins: {
"@functional": functionalPlugin,
"@typescript-eslint": tseslint.plugin,
"simple-import-sort": simpleImportSort,
jsdoc,
tsdoc: legacyPlugin("eslint-plugin-tsdoc", "tsdoc"),
"prefer-arrow-functions": legacyPlugin(
"eslint-plugin-prefer-arrow-functions",
"prefer-arrow-functions",
),
"filename-rules": legacyPlugin(
"eslint-plugin-filename-rules",
"filename-rules",
),
// FIXME eslint-plugin-jest needs type definitions
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
jest,
// FIXME eslint-plugin-no-secrets needs type definitions
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
"no-secrets": noSecrets,
"import-x": importX,
},
},
);
Loading