Skip to content

Commit

Permalink
Migrate eslint to flat config.
Browse files Browse the repository at this point in the history
Update dependencies.
  • Loading branch information
logue committed Apr 24, 2024
1 parent e16fe48 commit e679db4
Show file tree
Hide file tree
Showing 11 changed files with 1,421 additions and 1,260 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

44 changes: 0 additions & 44 deletions .eslintrc.yml

This file was deleted.

149 changes: 149 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import eslint from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import tseslint from 'typescript-eslint';

import pluginImport from 'eslint-plugin-import';
import pluginTsdoc from 'eslint-plugin-tsdoc';

/**
* ESLint Config
*/
export default tseslint.config(
{
ignores: [
'.vscode/',
'.yarn/',
'dist/',
'public/',
'src/**/*.generated.*',
'eslint.config.js',
],
},
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
{
languageOptions: {
parserOptions: {
project: [
'tsconfig.app.json',
'tsconfig.node.json',
'tsconfig.vitest.json',
],
tsconfigRootDir: import.meta.dirname,
extraFileExtensions: ['.vue'],
ecmaVersion: 'latest',
sourceType: 'module',
},
},
plugins: {
import: pluginImport,
tsdoc: pluginTsdoc,
},
settings: {
// This will do the trick
'import/parsers': {
espree: ['.js', '.cjs', '.mjs', '.jsx'],
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: true,
node: true,
alias: {
map: [
['@', './src'],
['~', './node_modules'],
],
extensions: ['.js', '.ts', '.jsx', '.tsx', '.vue'],
},
},
vite: {
configPath: './vite.config.ts',
},
},
rules: {
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-import-type-side-effects': 'error',
// ...importPlugin.configs["recommended"].rules,
'no-unused-vars': 'warn',
// const lines: string[] = []; style
'@typescript-eslint/array-type': [
'error',
{
default: 'array',
},
],
// Enable @ts-ignore etc.
'@typescript-eslint/ban-ts-comment': 'off',
// Left-hand side style
'@typescript-eslint/consistent-generic-constructors': [
'error',
'type-annotation',
],
// Enable import sort order, see bellow.
'@typescript-eslint/consistent-type-imports': [
'off',
{
prefer: 'type-imports',
},
],
// Fix for pinia
'@typescript-eslint/explicit-function-return-type': 'off',
// Allow short land for pretter
'@typescript-eslint/no-confusing-void-expression': [
'error',
{
ignoreArrowShorthand: true,
},
],
'@typescript-eslint/no-explicit-any': 'off',
// Fix for vite import.meta.env
'@typescript-eslint/strict-boolean-expressions': 'off',
// Fix for vite env.d.ts.
'@typescript-eslint/triple-slash-reference': 'off',
// Fix for Vue setup style
'import/default': 'off',
// Fix for Vue setup style
'import/no-default-export': 'off',
// Sort Import Order.
// see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md#importorder-enforce-a-convention-in-module-import-order
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'parent',
'sibling',
'index',
'object',
'type',
],
pathGroups: [
// Vue Core
{
pattern:
'{vue,vue-router,vuex,@/stores,vue-i18n,pinia,vite,vitest,vitest/**,@vitejs/**,@vue/**}',
group: 'external',
position: 'before',
},
// Internal Codes
{
pattern: '{@/**}',
group: 'internal',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['builtin'],
alphabetize: {
order: 'asc',
},
'newlines-between': 'always',
},
],
'tsdoc/syntax': 'warn',
},
},
// ...pluginVue.configs['flat/recommended'],
eslintConfigPrettier
);
40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@logue/reverb",
"version": "1.3.8",
"version": "1.3.9",
"description": "JavaScript Reverb effect class",
"keywords": [
"webaudio",
Expand Down Expand Up @@ -40,7 +40,7 @@
}
},
"engines": {
"node": ">=18.12.5",
"node": ">=20.1.3",
"yarn": ">=1.22.19"
},
"packageManager": "[email protected]",
Expand All @@ -59,36 +59,38 @@
"prepare": "husky install"
},
"dependencies": {
"@thi.ng/colored-noise": "^1.0.51",
"@thi.ng/transducers": "^8.8.26"
"@thi.ng/colored-noise": "^1.0.69",
"@thi.ng/transducers": "^9.0.3"
},
"devDependencies": {
"@tsconfig/node-lts": "^20.1.1",
"@types/node": "^20.11.13",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"bootstrap": "^5.3.2",
"eslint": "^8.56.0",
"@eslint/js": "^9.1.1",
"@tsconfig/node-lts": "^20.1.3",
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"bootstrap": "^5.3.3",
"eslint": "^9.1.1",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-html": "^8.1.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-n": "^17.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-tsdoc": "^0.2.17",
"eslint-plugin-yaml": "^0.5.0",
"husky": "^9.0.7",
"lint-staged": "^15.2.1",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.4",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"rollup-plugin-visualizer": "^5.12.0",
"typescript": "latest",
"vite": "^5.0.12",
"typescript": "^5.4.5",
"typescript-eslint": "^7.7.1",
"vite": "^5.2.10",
"vite-plugin-banner": "^0.7.1",
"vite-plugin-checker": "^0.6.2",
"vite-plugin-dts": "^3.7.2"
"vite-plugin-checker": "^0.6.4",
"vite-plugin-dts": "^3.9.0"
},
"husky": {
"hooks": {
Expand All @@ -106,4 +108,4 @@
"semver": "^7.5.3",
"yaml": "^2.3.2"
}
}
}
18 changes: 8 additions & 10 deletions src/Reverb.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import { defaults } from '@/interfaces/OptionInterface';
import Meta from '@/Meta';
import Noise, { type NoiseType } from '@/NoiseType';
import type OptionInterface from '@/interfaces/OptionInterface';

import {
blue,
green,
Expand All @@ -13,8 +8,14 @@ import {
type ColoredNoiseOpts,
} from '@thi.ng/colored-noise';
import { take } from '@thi.ng/transducers';

import type OptionInterface from '@/interfaces/OptionInterface';
import type { INorm } from '@thi.ng/random';

import Meta from '@/Meta';
import Noise, { type NoiseType } from '@/NoiseType';
import { defaults } from '@/interfaces/OptionInterface';

/**
* Reverb effect class
*/
Expand Down Expand Up @@ -300,10 +301,7 @@ export default class Reverb {
this.noise = white;
}
this.buildImpulse();
console.debug(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`[Reverb.js] Set IR generator source noise type to ${type}.`
);
console.debug(`[Reverb.js] Set IR generator source noise type to ${type}.`);
}

/**
Expand Down Expand Up @@ -350,7 +348,7 @@ export default class Reverb {

for (let i = 0; i < duration; i++) {
/** 減衰率 */
let n: number = 0;
let n = 0;

if (i < delayDuration) {
// Delay Effect
Expand Down
3 changes: 2 additions & 1 deletion src/interfaces/OptionInterface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SYSTEM } from '@thi.ng/random';
import type { INorm } from '@thi.ng/random';

import type { NoiseType } from '@/NoiseType';
import type { INorm } from '@thi.ng/random';

/** Reverb Option */
export default interface OptionInterface {
Expand Down
11 changes: 7 additions & 4 deletions tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"baseUrl": ".",
"esModuleInterop": true,
"moduleResolution": "Node",
"lib": ["DOM"],
"paths": { "@/*": ["./src/*"] }
"paths": {
"@/*": ["./src/*"]
},
"lib":[
"DOM"
]
}
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"compilerOptions": { "newLine": "lf" },
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" },
],
{ "path": "./tsconfig.node.json" }
]
}
13 changes: 11 additions & 2 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
{
"extends": ["@tsconfig/node-lts/tsconfig.json"],
"include": ["env.d.ts", "vite.config.*", "vitest.config.*", "package.json"],
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "@tsconfig/node-lts/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*",
"package.json"
],
"compilerOptions": {
"composite": true,
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"module": "ESNext",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
Expand Down
Loading

0 comments on commit e679db4

Please sign in to comment.