Skip to content

Commit

Permalink
!WIP! start migration to flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
darthmaim committed Dec 7, 2024
1 parent c206782 commit 1b2fc8b
Show file tree
Hide file tree
Showing 19 changed files with 221 additions and 330 deletions.
14 changes: 2 additions & 12 deletions apps/legacy-importer/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';
import config from '@gw2treasures/eslint-config';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default [...compat.extends('@gw2treasures/eslint-config')];
export default config;
2 changes: 0 additions & 2 deletions apps/legacy-importer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
"gw2-api-types": "0.0.8"
},
"devDependencies": {
"@eslint/eslintrc": "3.2.0",
"@eslint/js": "9.16.0",
"@gw2treasures/eslint-config": "workspace:*",
"@gw2treasures/tsconfig": "workspace:*",
"@types/node": "22.10.1",
Expand Down
4 changes: 3 additions & 1 deletion apps/web/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import nextJsPlugin from '@gw2treasures/eslint-plugin-nextjs';
import reactConfig from '@gw2treasures/eslint-config/react';
import reactCompiler from 'eslint-plugin-react-compiler';
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
Expand All @@ -12,7 +13,8 @@ const compat = new FlatCompat({

export default tseslint.config(
{ ignores: ['.next'] },
...compat.extends('next/core-web-vitals', '@gw2treasures/eslint-config/react'),
...compat.extends('next/core-web-vitals'),
...reactConfig,
{
plugins: {
'@gw2treasures/nextjs': nextJsPlugin,
Expand Down
14 changes: 2 additions & 12 deletions apps/worker/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';
import config from '@gw2treasures/eslint-config';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default [...compat.extends('@gw2treasures/eslint-config')];
export default config;
3 changes: 0 additions & 3 deletions apps/worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@
"sharp": "0.33.5"
},
"devDependencies": {
"@eslint/eslintrc": "3.2.0",
"@eslint/js": "9.16.0",
"@gw2api/types": "0.0.22",
"@gw2treasures/eslint-config": "workspace:*",
"@gw2treasures/tsconfig": "workspace:*",
"@types/jest": "29.5.14",
"@types/node": "22.10.1",
"@typescript-eslint/parser": "8.17.0",
"@vercel/ncc": "0.38.3",
"eslint": "9.16.0",
"jest": "29.7.0",
Expand Down
97 changes: 0 additions & 97 deletions packages/eslint-config/configs/index.json

This file was deleted.

85 changes: 85 additions & 0 deletions packages/eslint-config/configs/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import js from "@eslint/js";
import ts from 'typescript-eslint';
import importPlugin from 'eslint-plugin-import';
import stylistic from '@stylistic/eslint-plugin'

export default ts.config(
js.configs.recommended,
ts.configs.recommended,
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: {
'@stylistic': stylistic
},
rules: {
// `"foo"` → `'foo'`
"@stylistic/quotes": ["warn", "single"],

// `a => a` → `(a) => a`
"@stylistic/arrow-parens": "warn",

// `(a)=>a` → `(a) => a`
"@stylistic/arrow-spacing": "warn",

// `foo( bar )` → `foo(bar)`
"@stylistic/space-in-parens": "warn",

// disallows multipe spaces
"@stylistic/no-multi-spaces": "warn",

// disallow multiple empty lines
"@stylistic/no-multiple-empty-lines": "warn",

// only 1 property per line for objects (enforced only for > 3 properties or multiline values)
"@stylistic/object-curly-newline": ["warn", { "multiline": true, "consistent": true }],

// `{foo: bar}` → `{ foo: bar }`
"@stylistic/object-curly-spacing": ["warn", "always", { "objectsInObjects": false }],

// `{ foo:bar }` → `{ foo: bar }`
"@stylistic/key-spacing": "warn",

// `{ x: x }` → `{ x }`
"object-shorthand": "warn",

// allows (but does not require) dangling commas in multiline
"@stylistic/comma-dangle": ["warn", "only-multiline"],

// `foo(bar,baz)` → `foo(bar, baz)`
"@stylistic/comma-spacing": "warn",

// `1+1` → `1 + 1`
"@stylistic/space-infix-ops": "warn",

// require semicolon
"@stylistic/semi": "warn",

// no unnecessary semicolon
"@stylistic/no-extra-semi": ["warn"],

// disallows async functions not using await
"require-await": "warn",

// require dependencies to be in package.json
"import/no-extraneous-dependencies": "error",

// disable import/no-unresolved, ts is already handling this
"import/no-unresolved": "off",

// `const foo:Bar` → `const foo: Bar`
"@stylistic/type-annotation-spacing": "warn",

// `class foo_bar` → `class FooBar`
"@typescript-eslint/naming-convention": [
"warn",
{ "selector": "default", "format": null },
{ "selector": "typeLike", "format": ["PascalCase"] }
]
}
}
);
75 changes: 0 additions & 75 deletions packages/eslint-config/configs/react.json

This file was deleted.

Loading

0 comments on commit 1b2fc8b

Please sign in to comment.