Skip to content

Commit

Permalink
chore: replace tsjs with eslint config (#3496)
Browse files Browse the repository at this point in the history
  • Loading branch information
GermainBergeron authored Aug 2, 2023
1 parent 863cbda commit 345045e
Show file tree
Hide file tree
Showing 69 changed files with 1,190 additions and 2,236 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
extends: [require.resolve('tsjs/eslint-config')],
extends: ['plasma'],
ignorePatterns: ['scripts'],
};
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"printWidth": 120,
"tabWidth": 4,
"singleQuote": true,
"bracketSpacing": false
}
199 changes: 199 additions & 0 deletions helpers/eslint-config-plasma/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
/* eslint-env node */
module.exports = {
env: {
browser: true,
},
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'import', 'jsdoc', 'react', 'prefer-arrow', 'react-hooks', 'unused-imports'],
extends: ['plugin:react/jsx-runtime', 'prettier'],
settings: {
react: {
version: 'detect',
},
},
rules: {
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'off',
'@typescript-eslint/array-type': [
'error',
{
default: 'array-simple',
},
],
'@typescript-eslint/ban-types': [
'error',
{
types: {
Object: {
message: 'Avoid using the `Object` type. Did you mean `object`?',
},
Function: {
message: 'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.',
},
// eslint-disable-next-line id-blacklist
Boolean: {
message: 'Avoid using the `Boolean` type. Did you mean `boolean`?',
},
// eslint-disable-next-line id-blacklist
Number: {
message: 'Avoid using the `Number` type. Did you mean `number`?',
},
// eslint-disable-next-line id-blacklist
String: {
message: 'Avoid using the `String` type. Did you mean `string`?',
},
Symbol: {
message: 'Avoid using the `Symbol` type. Did you mean `symbol`?',
},
},
},
],
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'no-public',
},
],
'@typescript-eslint/indent': 'off',
'@typescript-eslint/member-delimiter-style': [
'off',
{
multiline: {
delimiter: 'none',
requireLast: true,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
},
],
'@typescript-eslint/naming-convention': ['warn', {selector: 'enumMember', format: null}],
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/quotes': 'off',
'@typescript-eslint/semi': ['off', null],
'@typescript-eslint/triple-slash-reference': 'error',
'@typescript-eslint/type-annotation-spacing': 'off',
'@typescript-eslint/unified-signatures': 'error',
'arrow-body-style': 'error',
'arrow-parens': ['off', 'always'],
'brace-style': ['off', 'off'],
'comma-dangle': 'off',
'constructor-super': 'error',
curly: 'error',
'default-case': 'error',
'eol-last': 'off',
eqeqeq: ['error', 'smart'],
'guard-for-in': 'error',
'id-blacklist': [
'error',
'any',
'Number',
'number',
'String',
'string',
'Boolean',
'boolean',
'Undefined',
'undefined',
],
'id-match': 'error',
'import/order': [
'error',
{
groups: [
['builtin', 'external', 'internal'],
['parent', 'sibling', 'index', 'object'],
],
},
],
'jsdoc/check-alignment': 'error',
'jsdoc/check-indentation': 'error',
'linebreak-style': 'off',
'max-len': [
'off',
{
code: 140,
},
],
'new-parens': 'off',
'newline-per-chained-call': 'off',
'no-bitwise': 'error',
'no-caller': 'error',
'no-cond-assign': 'error',
'no-console': [
'error',
{
allow: [
'warn',
'dir',
'timeLog',
'assert',
'clear',
'count',
'countReset',
'group',
'groupEnd',
'table',
'dirxml',
'error',
'groupCollapsed',
'Console',
'profile',
'profileEnd',
'timeStamp',
'context',
],
},
],
'no-debugger': 'error',
'no-duplicate-case': 'error',
'no-empty': 'error',
'no-eval': 'error',
'no-extra-semi': 'off',
'no-fallthrough': 'off',
'no-irregular-whitespace': 'off',
'no-multiple-empty-lines': 'off',
'no-new-wrappers': 'error',
'no-redeclare': 'error',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
'no-trailing-spaces': 'off',
'no-undef-init': 'error',
'no-underscore-dangle': 'error',
'no-unsafe-finally': 'error',
'no-unused-labels': 'error',
'no-var': 'error',
'one-var': ['error', 'never'],
'prefer-arrow/prefer-arrow-functions': 'error',
'prefer-const': 'error',
'quote-props': 'off',
radix: 'error',
'react/jsx-curly-spacing': 'off',
'react/jsx-equals-spacing': 'off',
'space-before-function-paren': 'off',
'space-in-parens': ['off', 'never'],
'spaced-comment': [
'error',
'always',
{
markers: ['/'],
},
],
'use-isnan': 'error',
'@typescript-eslint/no-unused-vars': 'off',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'warn',
{vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_'},
],
},
};
20 changes: 20 additions & 0 deletions helpers/eslint-config-plasma/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "eslint-config-plasma",
"version": "1.0.0",
"private": true,
"license": "Apache-2.0",
"author": "Coveo",
"main": "index.js",
"dependencies": {
"@typescript-eslint/eslint-plugin": "6.2.1",
"@typescript-eslint/parser": "6.2.1",
"eslint": "8.46.0",
"eslint-config-prettier": "8.9.0",
"eslint-plugin-import": "2.28.0",
"eslint-plugin-jsdoc": "46.4.5",
"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-react": "7.33.1",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-unused-imports": "3.0.0"
}
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"IE 11",
"not dead"
],
"prettier": "tsjs/prettier-config",
"stylelint": {
"extends": [
"stylelint-config-standard-scss"
Expand All @@ -67,6 +66,7 @@
"conventional-changelog-angular": "6.0.0",
"cz-conventional-changelog": "3.3.0",
"eslint": "8.45.0",
"eslint-config-plasma": "workspace:*",
"eslint-plugin-prettier": "5.0.0",
"husky": "8.0.3",
"lint-staged": "13.0.3",
Expand All @@ -75,7 +75,6 @@
"sort-package-json": "2.5.1",
"stylelint": "15.10.2",
"stylelint-config-standard-scss": "10.0.0",
"tsjs": "4.2.1",
"turbo": "1.10.9",
"underscore": "1.13.4",
"walkdir": "0.4.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/components-props-analyzer/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: [require.resolve('tsjs/eslint-config')],
extends: ['plasma'],
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: __dirname,
Expand Down
2 changes: 1 addition & 1 deletion packages/components-props-analyzer/bin/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: [require.resolve('tsjs/eslint-config')],
extends: ['plasma'],
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: __dirname,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const getPropsOfComponent = (component: Component, env: VirtualTypeScript
fileName,
content.length,
entry.name,
entry.source
entry.source,
);
if (symbol) {
const node = symbol.valueDeclaration || symbol.declarations?.[0];
Expand Down
6 changes: 3 additions & 3 deletions packages/components-props-analyzer/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const generateProps = async () => {
ensureDirSync('./src/components');
outputFileSync(
'./src/components/index.ts',
"// Don't edit this file, it is automatically generated on each build\n"
"// Don't edit this file, it is automatically generated on each build\n",
);
const env = buildTypeScriptEnvironment();

Expand All @@ -22,8 +22,8 @@ const generateProps = async () => {
`./src/components/${name}.ts`,
`// Don't edit this file, it is automatically generated on each build
import {ComponentMetadata} from '../ComponentsList';
export const ${name}Metadata: ComponentMetadata[] = ${JSON.stringify(props)};`
)
export const ${name}Metadata: ComponentMetadata[] = ${JSON.stringify(props)};`,
),
);
operations.push(appendFile('./src/components/index.ts', `export * from './${name}';\n`));
return Promise.all(operations);
Expand Down
1 change: 1 addition & 0 deletions packages/components-props-analyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +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 -c ./.eslintrc.js \"src/**/*.{ts,tsx}\" --fix",
"prettify": "prettier --write 'src/components/*.ts'",
"start": "nodemon"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/mantine/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
env: {
browser: true,
},
extends: [require.resolve('tsjs/eslint-config')],
extends: ['plasma'],
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: __dirname,
Expand Down
4 changes: 2 additions & 2 deletions packages/mantine/__mocks__/@monaco-editor/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const editor: any = {
focus: vi
.fn()
.mockImplementation(() =>
document.querySelector('[data-testid="monaco-editor"]').setAttribute('focus', 'true')
document.querySelector('[data-testid="monaco-editor"]').setAttribute('focus', 'true'),
),
trigger: vi
.fn()
.mockImplementation(() =>
document.querySelector('[data-testid="monaco-editor"]').setAttribute('trigger', 'true')
document.querySelector('[data-testid="monaco-editor"]').setAttribute('trigger', 'true'),
),
};

Expand Down
2 changes: 2 additions & 0 deletions packages/mantine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +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 -c ./.eslintrc.js \"src/**/*.{ts,tsx}\" --fix",
"start": "node ../../scripts/start",
"test": "TZ=UTC vitest run",
"test:watch": "TZ=UTC vitest",
Expand Down Expand Up @@ -75,6 +76,7 @@
"@types/testing-library__jest-dom": "5.14.8",
"csstype": "3.1.2",
"embla-carousel-react": "7.1.0",
"eslint-config-plasma": "workspace:*",
"eslint-plugin-testing-library": "5.11.0",
"eslint-plugin-vitest": "0.2.6",
"eslint-plugin-vitest-globals": "1.4.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/mantine/src/components/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const _Button = forwardRef<HTMLButtonElement, ButtonProps>(
/>
</ButtonWithDisabledTooltip>
);
}
},
);

export const Button = createPolymorphicComponent<'button', ButtonProps, {Group: typeof MantineButton.Group}>(_Button);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const _ButtonWithDisabledTooltip = forwardRef<HTMLDivElement, ButtonWithDisabled
</Tooltip>
) : (
<>{children}</>
)
),
);

export const ButtonWithDisabledTooltip = createPolymorphicComponent<'div', ButtonWithDisabledTooltipProps>(
_ButtonWithDisabledTooltip
_ButtonWithDisabledTooltip,
);
Loading

0 comments on commit 345045e

Please sign in to comment.