Skip to content

Commit

Permalink
chore: fix eslint configuration (#3851)
Browse files Browse the repository at this point in the history
  • Loading branch information
GermainBergeron authored Aug 13, 2024
1 parent a1bd708 commit 359a7d8
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 14 deletions.
8 changes: 2 additions & 6 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import vitest from 'eslint-plugin-vitest';
import reactRefresh from 'eslint-plugin-react-refresh';

export default tsEslint.config(
{ignores: ['**/dist', '**/.turbo', 'packages/react-icons/mock/index.js']},
{ignores: ['**/dist', '**/.turbo', 'packages/react-icons/mock/index.js', 'packages/website/src/examples/mantine']},
{
files: ['**/*.js', '**/*.jsx', '**/*.mjs', '**/*.cjs', '**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
extends: [tsEslint.configs.base, reactJsxRuntime, eslintConfigPrettier],
Expand All @@ -28,11 +28,7 @@ export default tsEslint.config(
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: [
'*.js',
'packages/react-icons/mock/index.tsx',
'packages/mantine/vitest.config.ts',
],
allowDefaultProject: ['*.js'],
},
jsxPragma: 'React',
},
Expand Down
4 changes: 2 additions & 2 deletions packages/components-props-analyzer/bin/getPropsOfComponent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {VirtualTypeScriptEnvironment} from '@typescript/vfs';
import ts from 'typescript';
import ts, {CompletionEntry} from 'typescript';

import {Component, ComponentMetadata} from '../src/ComponentsList';

Expand All @@ -17,7 +17,7 @@ export const getPropsOfComponent = (component: Component, env: VirtualTypeScript
env.createFile(fileName, content);
const {entries} = env.languageService.getCompletionsAtPosition(fileName, content.length + 1, {
triggerKind: ts.CompletionTriggerKind.Invoked,
}) ?? {entries: []};
}) ?? {entries: [] as CompletionEntry[]};

const checker = env.languageService.getProgram()!.getTypeChecker();
const accumulator: ComponentMetadata[] = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/components-props-analyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"clean": "rimraf dist",
"compile": "node ../../scripts/build",
"gen:props": "ts-node --project ./bin/tsconfig.json ./bin/index.ts",
"lintfix": "../../node_modules/.bin/prettier --write \"**/*.{scss,ts,tsx,js,jsx,json,md,yml,html}\" && ../../node_modules/.bin/eslint \"src/**/*.{ts,tsx}\" --fix",
"lintfix": "../../node_modules/.bin/prettier --write \"**/*.{scss,ts,tsx,js,jsx,json,md,yml,html}\" && ../../node_modules/.bin/eslint \"**/*.{ts,tsx}\" --fix",
"prettify": "prettier --write \"src/components/*.ts\"",
"start": "nodemon"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/components-props-analyzer/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["./src"]
}
2 changes: 1 addition & 1 deletion packages/mantine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"scripts": {
"build": "node ../../scripts/build",
"clean": "rimraf dist",
"lintfix": "../../node_modules/.bin/prettier --write \"**/*.{scss,ts,tsx,js,jsx,json,md,yml,html}\" && ../../node_modules/.bin/eslint \"src/**/*.{ts,tsx}\" --fix",
"lintfix": "../../node_modules/.bin/prettier --write \"**/*.{scss,ts,tsx,js,jsx,json,md,yml,html}\" && ../../node_modules/.bin/eslint \"**/*.{ts,tsx}\" --fix",
"prepublishOnly": "publint",
"start": "node ../../scripts/start",
"test": "TZ=UTC vitest run",
Expand Down
5 changes: 5 additions & 0 deletions packages/mantine/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "./tsconfig.json",
"include": ["./src"],
"exclude": ["./src/__tests__", "**/*.spec.*"]
}
1 change: 1 addition & 0 deletions packages/react-icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"build:mock": "swc ./mock/index.tsx -o ./mock/index.js --config-file ./mock/.swcrc",
"clean": "rimraf dist",
"generate": "node ./bin/index.js",
"lintfix": "../../node_modules/.bin/prettier --write \"**/*.{scss,ts,tsx,js,jsx,json,md,yml,html}\" && ../../node_modules/.bin/eslint \"**/*.{ts,tsx}\" --fix",
"prepublishOnly": "publint"
},
"dependencies": {
Expand Down
4 changes: 4 additions & 0 deletions packages/react-icons/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["./src"]
}
2 changes: 1 addition & 1 deletion packages/tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
],
"scripts": {
"build": "rimraf dist && node ../../scripts/build",
"lintfix": "../../node_modules/.bin/prettier --write \"**/*.{scss,ts,tsx,js,jsx,json,md,yml,html}\" && ../../node_modules/.bin/eslint \"bin/**/*.{ts,tsx}\" --fix",
"lintfix": "../../node_modules/.bin/prettier --write \"**/*.{scss,ts,tsx,js,jsx,json,md,yml,html}\" && ../../node_modules/.bin/eslint \"**/*.{ts,tsx}\" --fix",
"prepublishOnly": "publint",
"tokens:build": "ts-node ./bin/build.ts --project ./bin/tsconfig.json && pnpm tokens:lint",
"tokens:fetch": "ts-node -r dotenv-safe/config --project ./bin/tsconfig.json ./bin/fetch.ts",
Expand Down
4 changes: 4 additions & 0 deletions packages/tokens/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["./src"]
}
4 changes: 2 additions & 2 deletions packages/tsconfig-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lib": ["ESNext", "DOM"],

"outDir": "${configDir}/dist",
"rootDir": "${configDir}/src",
"rootDirs": ["${configDir}/src", "${configDir}/__mocks__"],
"tsBuildInfoFile": "${configDir}/dist/.tsbuildinfo",
"baseUrl": "${configDir}",

Expand All @@ -33,5 +33,5 @@
"esModuleInterop": true,
"importHelpers": true
},
"include": ["${configDir}/src"]
"exclude": ["${configDir}/dist", "${configDir}/node_modules"]
}
1 change: 1 addition & 0 deletions packages/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"type": "module",
"scripts": {
"build": "tsc && vite build",
"lintfix": "../../node_modules/.bin/prettier --write \"**/*.{scss,ts,tsx,js,jsx,json,md,yml,html}\" && ../../node_modules/.bin/eslint \"**/*.{ts,tsx}\" --fix",
"mantine:fetch": "ts-node --project ./bin/tsconfig.json ./bin/index.ts",
"preview": "vite preview",
"start": "vite"
Expand Down
5 changes: 4 additions & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
const {spawn} = require('child_process');
const path = require('path');
const {writeFileSync} = require('node:fs');
const {existsSync, writeFileSync} = require('node:fs');
process.on('unhandledRejection', (err) => {
throw err;
});
Expand All @@ -22,6 +22,9 @@ const build = async ({watch = false}) => {
// compile with swc and tsc
try {
const tscArgs = ['--emitDeclarationOnly'];
if (existsSync('./tsconfig.build.json')) {
tscArgs.push('--project', './tsconfig.build.json');
}
const tscESMArgs = [...tscArgs, '--declarationDir', './dist/esm'];
const tscCJSArgs = [...tscArgs, '--declarationDir', './dist/cjs', '--target', 'es5', '--module', 'commonjs'];
const swcArgs = ['./src', '--copy-files', '--config-file', path.resolve(__dirname, '..', 'build.swcrc')];
Expand Down

0 comments on commit 359a7d8

Please sign in to comment.