Skip to content

Commit

Permalink
Better initial overrides for eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
vilicvane committed Oct 15, 2023
1 parent 4d832b1 commit 13e909b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 19 deletions.
63 changes: 44 additions & 19 deletions general/src/composables/eslintrc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type {JSONFileOptions} from '@magicspace/core';
import {json} from '@magicspace/core';
import {json, composable} from '@magicspace/core';

import type {ResolvedOptions} from '../library/index.js';

const JSON_OPTIONS: JSONFileOptions = {
/** @link https://eslint.org/docs/user-guide/configuring */
Expand All @@ -21,21 +23,44 @@ const JSON_OPTIONS: JSONFileOptions = {
],
};

export default json(
'.eslintrc.json',
{
root: true,
ignorePatterns: ['node_modules/'],
extends: ['plugin:@mufan/javascript'],
overrides: [
{files: '**/*.{js,jsx}'},
{
files: '**/*.cjs',
parserOptions: {
sourceType: 'script',
},
},
],
},
JSON_OPTIONS,
);
export default composable<ResolvedOptions>(({type}) => {
const esm = type === 'module';

return json(
'.eslintrc.json',
{
root: true,
ignorePatterns: ['node_modules/'],
extends: ['plugin:@mufan/javascript'],
overrides: [
esm
? {
files: '**/*.{js,mjs}',
parserOptions: {
sourceType: 'module',
},
}
: {
files: '**/*.{js,cjs}',
parserOptions: {
sourceType: 'script',
},
},
esm
? {
files: '**/*.cjs',
parserOptions: {
sourceType: 'script',
},
}
: {
files: '**/*.mjs',
parserOptions: {
sourceType: 'module',
},
},
],
},
JSON_OPTIONS,
);
});
2 changes: 2 additions & 0 deletions typescript/src/composables/vscode-settings.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export default composable<ResolvedOptions>(
data = extendObjectProperties(
data,
{
'typescript.preferences.importModuleSpecifier': 'project-relative',
'typescript.preferences.importModuleSpecifierEnding': 'js',
'typescript.tsdk': 'node_modules/typescript/lib',
},
{
Expand Down

0 comments on commit 13e909b

Please sign in to comment.