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
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ npm install --save-dev @boehringer-ingelheim/eslint-config

### Add the configuration

Create or update the `eslint.config.mjs` (`eslint.config.cjs` is also possible if commonjs is preferred) file in your projects root directory accordingly.
Create or update the `eslint.config.mjs` file in your projects root directory accordingly.

```js
import boehringer from '@boehringer-ingelheim/eslint-config';
Expand Down Expand Up @@ -223,7 +223,7 @@ export default defineConfig(
);
```

This shared ESLint configuration is designed to enforce some naming conventions. It uses the [`@typescript-eslint/naming-convention`](https://typescript-eslint.io/rules/naming-convention/) rule for enforcing the naming conventions. The enforced conventions can be found in [configs/naming-convention.js](./configs/naming-convention.js#L7-L65)
This shared ESLint configuration is designed to enforce some naming conventions. It uses the [`@typescript-eslint/naming-convention`](https://typescript-eslint.io/rules/naming-convention/) rule for enforcing the naming conventions. The enforced conventions can be found in [configs/experimental-naming-convention.js](./configs/experimental-naming-convention.js#L7-L65)

### Prettier-disable

Expand Down
18 changes: 9 additions & 9 deletions configs/base.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
const eslint = require('@eslint/js');
const importPlugin = require('eslint-plugin-import');
const perfectionist = require('eslint-plugin-perfectionist');
const sonarjs = require('eslint-plugin-sonarjs');
const { defineConfig } = require('eslint/config');
const tseslint = require('typescript-eslint');
import eslint from '@eslint/js';
import importPlugin from 'eslint-plugin-import';
import perfectionist from 'eslint-plugin-perfectionist';
import sonarjs from 'eslint-plugin-sonarjs';
import { defineConfig } from 'eslint/config';
import tseslint from 'typescript-eslint';

const {
import {
PERFECTIONIST_SETTINGS,
SORT_CLASSES_GROUPS,
SORT_IMPORTS_GROUPS,
SORT_INTERSECTION_TYPES_GROUPS,
} = require('../lib/eslint-plugin-perfectionist.js');
} from '../lib/eslint-plugin-perfectionist.js';

module.exports = defineConfig(
export default defineConfig(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
tseslint.configs.stylisticTypeChecked,
Expand Down
4 changes: 2 additions & 2 deletions configs/experimental-naming-convention.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { defineConfig } = require('eslint/config');
import { defineConfig } from 'eslint/config';

module.exports = defineConfig({
export default defineConfig({
rules: {
'@typescript-eslint/naming-convention': [
'error',
Expand Down
6 changes: 3 additions & 3 deletions configs/local.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { defineConfig } = require('eslint/config');
const isCI = require('is-ci');
import { defineConfig } from 'eslint/config';
import isCI from 'is-ci';

module.exports = defineConfig(
export default defineConfig(
isCI
? {}
: {
Expand Down
10 changes: 5 additions & 5 deletions configs/nextjs.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const nextPlugin = require('@next/eslint-plugin-next');
const { defineConfig } = require('eslint/config');
import nextPlugin from '@next/eslint-plugin-next';
import { defineConfig } from 'eslint/config';

const { NEXTJS_ROUTING_FILES } = require('../lib/nextjs.utils.js');
const react = require('./react.js');
import { NEXTJS_ROUTING_FILES } from '../lib/nextjs.utils.js';
import react from './react.js';

module.exports = defineConfig(
export default defineConfig(
...react,
{
plugins: {
Expand Down
6 changes: 3 additions & 3 deletions configs/playwright.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const playwright = require('eslint-plugin-playwright');
const { defineConfig } = require('eslint/config');
import playwright from 'eslint-plugin-playwright';
import { defineConfig } from 'eslint/config';

module.exports = defineConfig({
export default defineConfig({
...playwright.configs['flat/recommended'],
rules: {
/**
Expand Down
6 changes: 3 additions & 3 deletions configs/prettier-disable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const prettier = require('eslint-config-prettier');
const { defineConfig } = require('eslint/config');
import prettier from 'eslint-config-prettier';
import { defineConfig } from 'eslint/config';

module.exports = defineConfig({
export default defineConfig({
...prettier,
rules: {
...prettier.rules,
Expand Down
19 changes: 10 additions & 9 deletions configs/react.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const jsxA11y = require('eslint-plugin-jsx-a11y');
const react = require('eslint-plugin-react');
const reactHooks = require('eslint-plugin-react-hooks');
const reactRefresh = require('eslint-plugin-react-refresh');
const { defineConfig } = require('eslint/config');
const globals = require('globals');
const { PERFECTIONIST_SETTINGS, SORT_IMPORTS_GROUPS } = require('../lib/eslint-plugin-perfectionist.js');
const base = require('./base.js');
import jsxA11y from 'eslint-plugin-jsx-a11y';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import { defineConfig } from 'eslint/config';
import globals from 'globals';

module.exports = defineConfig(
import { PERFECTIONIST_SETTINGS, SORT_IMPORTS_GROUPS } from '../lib/eslint-plugin-perfectionist.js';
import base from './base.js';

export default defineConfig(
...base,
jsxA11y.flatConfigs.recommended,
react.configs.flat.recommended,
Expand Down
8 changes: 4 additions & 4 deletions configs/strict.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { defineConfig } = require('eslint/config');
const tseslint = require('typescript-eslint');
import { defineConfig } from 'eslint/config';
import tseslint from 'typescript-eslint';

const base = require('./base.js');
import base from './base.js';

module.exports = defineConfig(...base, tseslint.configs.strictTypeChecked, {
export default defineConfig(...base, tseslint.configs.strictTypeChecked, {
rules: {
// @typescript-eslint: https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin/docs/rules
'@typescript-eslint/consistent-type-imports': 'error',
Expand Down
12 changes: 8 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Linter } from 'eslint';
import type tseslint from 'typescript-eslint';

type Configs =
| 'base'
Expand All @@ -10,8 +11,9 @@ type Configs =
| 'react'
| 'strict';

declare module './index.js' {
export const configs: Record<Configs, Linter.Config[]>;
declare const boehringerConfig: {
config: typeof tseslint.config;
configs: Record<Configs, Linter.Config[]>;
/**
* Reads an ignore file (e.g. `.gitignore`) and returns an object with the ignore patterns.
*
Expand All @@ -20,5 +22,7 @@ declare module './index.js' {
* @throws {Error} If the provided path is an empty string.
* @returns {Linter.Config} The result of including the ignore file at the resolved absolute path.
*/
export const includeIgnoreFile: (ignoreFilePath?: string) => Linter.Config;
}
includeIgnoreFile: (ignoreFilePath?: string) => Linter.Config;
};

export default boehringerConfig;
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const tseslint = require('typescript-eslint');
import tseslint from 'typescript-eslint';

const base = require('./configs/base.js');
const experimentalNamingConvention = require('./configs/experimental-naming-convention.js');
const local = require('./configs/local.js');
const nextjs = require('./configs/nextjs.js');
const playwright = require('./configs/playwright.js');
const prettierDisable = require('./configs/prettier-disable.js');
const react = require('./configs/react.js');
const strict = require('./configs/strict.js');
const { includeIgnoreFile } = require('./lib/include-ignore-file.js');
import base from './configs/base.js';
import experimentalNamingConvention from './configs/experimental-naming-convention.js';
import local from './configs/local.js';
import nextjs from './configs/nextjs.js';
import playwright from './configs/playwright.js';
import prettierDisable from './configs/prettier-disable.js';
import react from './configs/react.js';
import strict from './configs/strict.js';
import { includeIgnoreFile } from './lib/include-ignore-file.js';

module.exports = {
export default {
config: tseslint.config,
configs: {
base,
Expand Down
2 changes: 1 addition & 1 deletion lib/eslint-plugin-perfectionist.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const SORT_INTERSECTION_TYPES_GROUPS = [
'unknown',
];

module.exports = {
export {
PERFECTIONIST_SETTINGS,
SORT_CLASSES_GROUPS,
SORT_IMPORTS_GROUPS,
Expand Down
12 changes: 4 additions & 8 deletions lib/include-ignore-file.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { includeIgnoreFile: includeIgnoreFileAbsolute } = require('@eslint/compat');
const path = require('node:path');
const { cwd } = require('node:process');
import { includeIgnoreFile as includeIgnoreFileAbsolute } from '@eslint/compat';
import path from 'node:path';
import { cwd } from 'node:process';

/**
* Reads an ignore file (e.g. `.gitignore`) and returns an object with the ignore patterns.
Expand All @@ -10,7 +10,7 @@ const { cwd } = require('node:process');
* @throws {Error} If the provided path is an empty string.
* @returns {import('@eslint/compat').FlatConfig} The result of including the ignore file at the resolved absolute path.
*/
const includeIgnoreFile = (ignoreFilePath = '.gitignore') => {
export const includeIgnoreFile = (ignoreFilePath = '.gitignore') => {
if (typeof ignoreFilePath !== 'string') {
throw new TypeError('Expected a string');
}
Expand All @@ -22,7 +22,3 @@ const includeIgnoreFile = (ignoreFilePath = '.gitignore') => {
const absolutePath = path.resolve(cwd(), ignoreFilePath);
return includeIgnoreFileAbsolute(absolutePath);
};

module.exports = {
includeIgnoreFile,
};
4 changes: 1 addition & 3 deletions lib/nextjs.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ const NEXTJS_ROUTING_FILES = [
'template',
];

module.exports = {
NEXTJS_ROUTING_FILES,
};
export { NEXTJS_ROUTING_FILES };
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@boehringer-ingelheim/eslint-config",
"version": "9.1.0",
"version": "0.0.0-semantically-released",
"type": "module",
"description": "Shared eslint configuration used at Boehringer Ingelheim for code styling",
"keywords": [
"boehringer",
Expand Down Expand Up @@ -28,6 +29,13 @@
"index.d.ts"
],
"main": "index.js",
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.js",
"default": "./index.js"
}
},
"types": "index.d.ts",
"scripts": {
"prepare": "husky",
Expand Down