Skip to content

Commit

Permalink
build: update eslint.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB committed Apr 9, 2024
1 parent 12f99d0 commit 841cb51
Show file tree
Hide file tree
Showing 14 changed files with 246 additions and 327 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

135 changes: 0 additions & 135 deletions .eslintrc.json

This file was deleted.

137 changes: 137 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// @ts-check
import 'tsx';

import { FlatCompat } from '@eslint/eslintrc';

import globals from 'globals';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslintPluginYml from 'eslint-plugin-yml';
import eslint from '@eslint/js';
import { parse, parseForESLint } from '@typescript-eslint/parser';
const eslintPluginLyne = await import('./tools/eslint/index.ts');

const compat = new FlatCompat({
baseDirectory: import.meta.resolve('.'),
});

/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */
export default [
{
settings: {
'import-x/resolver': {
typescript: true,
},
},
},
{
languageOptions: {
globals: { ...globals.browser },
ecmaVersion: 2020,
parser: { parse, parseForESLint },
},
},
{
ignores: [
'**/*.chromatic.stories.*',
'dist/**/*',
'tools/generate-component/boilerplate/**/*',
'**/__snapshots__/**/*',
],
},
eslint.configs.recommended,
...tseslint.configs.recommended,
...eslintPluginYml.configs['flat/standard'],
...eslintPluginYml.configs['flat/prettier'],
...compat.extends(
'plugin:lit/recommended',
'plugin:import-x/recommended',
'plugin:import-x/typescript',
),
eslintPluginLyne.default.configs.recommended,
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-function-return-type': ['warn', { allowExpressions: true }],
'@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/naming-convention': [
'error',
{
format: ['PascalCase'],
selector: 'interface',
},
{
format: ['camelCase'],
selector: 'default',
},
{
format: ['camelCase', 'UPPER_CASE'],
selector: 'variable',
},
{
format: ['camelCase'],
leadingUnderscore: 'allow',
selector: 'parameter',
},
{
format: ['camelCase'],
leadingUnderscore: 'require',
modifiers: ['private'],
selector: 'memberLike',
},
{
format: ['PascalCase'],
selector: 'typeLike',
},
{
format: null,
selector: 'objectLiteralProperty',
},
],
// TODO: Remove this after fixing issues
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-use-before-define': 'error',
// TODO: Evaluate this rule
'@typescript-eslint/semi': 'error',

'import-x/first': 'error',
'import-x/no-absolute-path': 'error',
'import-x/no-cycle': 'error',
'import-x/no-self-import': 'error',
'import-x/no-unresolved': [
'error',
{
ignore: [
'\\.md\\?raw$',
'\\.svg\\?raw$',
'\\.scss\\?lit\\&inline',
// Broken. Maybe due to commonjs?
'@storybook/addon-actions/decorator',
],
},
],
'import-x/no-useless-path-segments': 'error',
'import-x/order': [
'error',
{
alphabetize: { order: 'asc', caseInsensitive: true },
'newlines-between': 'always',
},
],
// TODO Discuss this with the team
'lit/no-invalid-html': 'off',
camelcase: 'off',
},
},

eslintConfigPrettier,
];
23 changes: 13 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@
"@commitlint/config-conventional": "19.1.0",
"@custom-elements-manifest/analyzer": "0.9.4",
"@custom-elements-manifest/to-markdown": "0.1.0",
"@eslint/eslintrc": "3.0.2",
"@eslint/js": "9.0.0",
"@lit-labs/testing": "0.2.3",
"@lit/react": "^1.0.1",
"@lit/react": "1.0.4",
"@open-wc/lit-helpers": "0.7.0",
"@open-wc/testing": "4.0.0",
"@sbb-esta/lyne-design-tokens": "0.5.0",
Expand All @@ -78,40 +80,40 @@
"@storybook/web-components": "8.0.6",
"@storybook/web-components-vite": "8.0.6",
"@types/glob": "8.1.0",
"@types/mocha": "^10.0.4",
"@types/mocha": "10.0.6",
"@types/node": "20.12.5",
"@types/react": "18.2.75",
"@types/react-dom": "^18.2.15",
"@types/react-dom": "18.2.24",
"@typescript-eslint/eslint-plugin": "7.6.0",
"@typescript-eslint/parser": "7.6.0",
"@web/test-runner": "0.18.1",
"@web/test-runner-commands": "0.9.0",
"@web/test-runner-playwright": "0.11.0",
"@web/test-runner-puppeteer": "0.16.0",
"chromatic": "11.3.0",
"custom-elements-manifest": "^2.0.0",
"custom-elements-manifest": "2.0.0",
"date-fns": "3.6.0",
"esbuild-sass-plugin": "^3.1.0",
"esbuild-sass-plugin": "3.2.0",
"eslint": "9.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-import": "npm:eslint-plugin-i@latest",
"eslint-plugin-import-x": "0.5.0",
"eslint-plugin-lit": "1.11.0",
"eslint-plugin-lyne": "file:tools/eslint/link/",
"eslint-plugin-react": "7.34.1",
"eslint-plugin-storybook": "0.8.0",
"eslint-plugin-yaml": "0.5.0",
"eslint-plugin-yml": "1.14.0",
"glob": "10.3.12",
"globals": "15.0.0",
"husky": "9.0.11",
"lint-staged": "15.2.2",
"lit-analyzer": "2.0.3",
"madge": "7.0.0",
"npm-run-all2": "6.1.2",
"playwright": "^1.41.1",
"playwright": "1.43.0",
"postcss": "8.4.38",
"prettier": "3.2.5",
"react": "18.2.0",
"react-dom": "^18.2.0",
"react-dom": "18.2.0",
"rollup-plugin-postcss-lit": "2.1.0",
"sass": "1.74.1",
"sinon": "17.0.1",
Expand All @@ -123,6 +125,7 @@
"ts-lit-plugin": "2.0.2",
"tsx": "4.7.2",
"typescript": "5.4.4",
"typescript-eslint": "7.6.0",
"vite": "5.2.8",
"vite-plugin-dts": "3.8.1"
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/link/common/block-link-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { AbstractConstructor } from '../../core/mixins/index.js';
import { SbbIconNameMixin } from '../../icon/index.js';

import { SbbLinkCommonElementMixin, type SbbLinkCommonElementMixinType } from './link-common.js';
// eslint-disable-next-line import/order
// eslint-disable-next-line import-x/order
import blockStyle from './block-link.scss?lit&inline';
import style from './link.scss?lit&inline';

Expand Down
2 changes: 1 addition & 1 deletion src/components/link/common/inline-link-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { SbbActionBaseElement } from '../../core/base-elements/index.js';
import type { AbstractConstructor } from '../../core/mixins/index.js';

import { SbbLinkCommonElementMixin, type SbbLinkCommonElementMixinType } from './link-common.js';
// eslint-disable-next-line import/order
// eslint-disable-next-line import-x/order
import inlineStyle from './inline-link.scss?lit&inline';
import style from './link.scss?lit&inline';

Expand Down
2 changes: 1 addition & 1 deletion tools/eslint/custom-element-class-name-rule.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention, import/no-unresolved */
/* eslint-disable @typescript-eslint/naming-convention, import-x/no-unresolved */
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
import { ESLintUtils, AST_NODE_TYPES } from '@typescript-eslint/utils';

Expand Down
2 changes: 1 addition & 1 deletion tools/eslint/custom-element-decorator-position-rule.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention, import/no-unresolved */
/* eslint-disable @typescript-eslint/naming-convention, import-x/no-unresolved */
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
import { ESLintUtils } from '@typescript-eslint/utils';

Expand Down
2 changes: 1 addition & 1 deletion tools/eslint/import-extension-rule.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention, import/no-unresolved */
/* eslint-disable @typescript-eslint/naming-convention, import-x/no-unresolved */
import { existsSync, statSync } from 'fs';
import { dirname, resolve } from 'path';

Expand Down
Loading

0 comments on commit 841cb51

Please sign in to comment.