Skip to content

Commit

Permalink
feat: update eslint config to flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
AlasDiablo committed Oct 4, 2024
1 parent 27c3dab commit 038e05b
Show file tree
Hide file tree
Showing 15 changed files with 2,235 additions and 1,224 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22.9.0
61 changes: 61 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import draconidesBaseConfig from '@draconides/eslint-config-base';
// import draconidesTsConfig from '@draconides/eslint-config-ts';
import jsdoc from 'eslint-plugin-jsdoc';
import tsdoc from 'eslint-plugin-tsdoc';
import globals from 'globals';

import { fileURLToPath } from 'node:url';

const __dirname = fileURLToPath(new URL('.', import.meta.url));

export default [
...draconidesBaseConfig,
// ...draconidesTsConfig,
{
plugins: {
jsdoc,
tsdoc,
},

languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest,
},
parserOptions: {
projectService: true,
project: './tsconfig.eslint.json',
tsconfigRootDir: __dirname,
},
},

rules: {
'jsdoc/check-alignment': 1,
'jsdoc/check-param-names': 1,
'jsdoc/check-property-names': 1,
'jsdoc/check-tag-names': 1,
'jsdoc/check-values': 1,
'jsdoc/empty-tags': 1,
'jsdoc/implements-on-classes': 1,
'jsdoc/multiline-blocks': 1,
'jsdoc/no-multi-asterisks': 1,
'jsdoc/require-jsdoc': 1,
'jsdoc/require-param': 1,
'jsdoc/require-param-description': 1,
'jsdoc/require-param-name': 1,
'jsdoc/require-property': 1,
'jsdoc/require-property-description': 1,
'jsdoc/require-property-name': 1,
'jsdoc/require-returns': 1,
'jsdoc/require-returns-check': 1,
'jsdoc/require-returns-description': 1,
'jsdoc/require-throws': 1,
'jsdoc/require-yields': 1,
'jsdoc/require-yields-check': 1,
'jsdoc/sort-tags': 1,
'jsdoc/tag-lines': 1,
'tsdoc/syntax': 'warn',
},
},
];
2,893 changes: 1,883 additions & 1,010 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 15 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@
"devDependencies": {
"@draconides/eslint-config-base": "*",
"@draconides/eslint-config-ts": "*",
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.11.1",
"@microsoft/tsdoc": "^0.15.0",
"@microsoft/tsdoc-config": "^0.17.0",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^46.10.1",
"eslint-plugin-tsdoc": "^0.2.17",
"lerna": "^8.1.6",
"typedoc": "^0.26.4",
"typescript": "^5.0.4"
"eslint": "^9.11.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsdoc": "^50.3.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-tsdoc": "^0.3.0",
"globals": "^15.10.0",
"lerna": "^8.1.8",
"prettier": "^3.3.3",
"typedoc": "^0.26.7",
"typescript": "^5.6.2",
"typescript-eslint": "^8.8.0"
}
}
9 changes: 9 additions & 0 deletions packages/eslint-config-base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ This module of Draconides is a configuration for ESLint
```bash
npm install --save-dev @draconides/eslint-config-base
```

### Require

- `@eslint/js`: `^9.0.0`
- `eslint`: `^8.0.0 || ^9.0.0`
- `eslint-config-prettier`: `^9.0.0`
- `eslint-plugin-import`: `^2.31.0`
- `eslint-plugin-prettier`: `^5.0.0`
- `prettier`: `^3.0.0`
71 changes: 0 additions & 71 deletions packages/eslint-config-base/index.js

This file was deleted.

95 changes: 95 additions & 0 deletions packages/eslint-config-base/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import js from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import importPlugin from 'eslint-plugin-import';
import eslintPluginPrettier from 'eslint-plugin-prettier/recommended';

export default [
eslintPluginPrettier,
eslintConfigPrettier,
js.configs.recommended,
importPlugin.flatConfigs.recommended,
{
files: ['**/*.{js,mjs,cjs}'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
'prettier/prettier': [
'error',
{
singleQuote: true,
trailingComma: 'all',
tabWidth: 4,
bracketSpacing: true,
arrowParens: 'always',
endOfLine: 'lf',
semi: true,
},
],

'no-console': 'warn',
'linebreak-style': ['error', 'unix'],

'no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: false,
},
],

'no-import-assign': 'error',

'no-undef': [
'error',
{
typeof: true,
},
],

'no-unexpected-multiline': 'error',
'no-self-assign': 'error',
'no-unreachable': 'error',
'no-unreachable-loop': 'error',
'no-unsafe-optional-chaining': 'error',
'no-use-before-define': 'error',
'no-useless-backreference': 'error',

'valid-typeof': [
'error',
{
requireStringLiterals: false,
},
],

camelcase: 'error',
curly: 'error',
eqeqeq: 'error',
'no-shadow': 'error',
'no-var': 'error',
radix: 'error',
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-namespace': 'error',
'import/no-empty-named-blocks': 'error',
'import/no-useless-path-segments': 'error',
'import/consistent-type-specifier-style': 'error',

'import/order': [
'error',
{
groups: ['index', 'sibling', 'parent', 'internal', 'external', 'builtin', 'object', 'type'],

alphabetize: {
order: 'asc',
caseInsensitive: true,
},

'newlines-between': 'always',
},
],
},
},
];
23 changes: 13 additions & 10 deletions packages/eslint-config-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
"author": "AlasDiablo <25723276+AlasDiablo@users.noreply.github.com>",
"homepage": "https://github.com/AlasDiablo/draconides#readme",
"license": "CECILL-C",
"main": "index.js",
"main": "index.mjs",
"module": "index.mjs",
"files": [
"index.js"
"index.mjs"
],
"repository": {
"type": "git",
Expand All @@ -23,17 +24,19 @@
"bugs": {
"url": "https://github.com/AlasDiablo/draconides/issues"
},
"dependencies": {
"eslint": "^8.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.0.0",
"eslint-plugin-prettier": "^5.0.0",
"prettier": "^3.0.0"
"devDependencies": {
"@eslint/js": "^9.11.1",
"eslint": "^9.11.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.1",
"prettier": "^3.3.3"
},
"peerDependencies": {
"eslint": "^8.0.0",
"@eslint/js": "^9.0.0",
"eslint": "^8.0.0 || ^9.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.0.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.0.0",
"prettier": "^3.0.0"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/eslint-config-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ This module of Draconides is a configuration for ESLint for React
```bash
npm install --save-dev @draconides/eslint-config-react
```

### Require

- `@eslint/js`: `^9.0.0`
- `eslint`: `^8.0.0 || ^9.0.0`
- `eslint-plugin-jsx-a11y`: `^6.10.0`
- `eslint-plugin-react`: `^7.37.0`
- `eslint-plugin-react-hooks`: `^5.1.0`
30 changes: 0 additions & 30 deletions packages/eslint-config-react/index.js

This file was deleted.

Loading

0 comments on commit 038e05b

Please sign in to comment.