Skip to content

Commit 21e26b0

Browse files
authored
Support .ts(x) eslint linting (codesandbox#2143)
* Demo linting errors * ⚙️ Config: Add TypeScript validation to VSCode ESLint Settings This appears to be a solution to ESLint not working on TypeScript files in VSCode. It doesn't solve issues in other editors, but right now it would appear that getting ESLint to work with TypeScript is difficult to do in general. * app eslint: also check .ts(x) files. * app typecheck: really exclude overmind. * app eslint: ignore overmind (for now). * Fix ESLint errors/warnings on linting-issues-repro branch (codesandbox#2154) * Fix ESLint errors * Fix some more ESLint errors * Ignore packages/app/src/app/vscode folder * Fix some more ESLint errors * Resolve discussions * Resolve some more discussions * Fix 0 check on number * Change undefined value * Make function name more explicit * Change undefined behaviour * Support importing types in linter
1 parent 522cd7f commit 21e26b0

File tree

53 files changed

+404
-376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+404
-376
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"warn",
5050
{ "aspects": ["noHref", "invalidHref"] }
5151
],
52-
"jsx-a11y/label-has-for": "off"
52+
"jsx-a11y/label-has-for": "off",
53+
"no-bitwise": "off"
5354
},
5455
"overrides": [
5556
{

.vscode/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
22
"eslint.enable": true,
3-
"typescript.tsdk": "node_modules/typescript/lib"
3+
"typescript.tsdk": "node_modules/typescript/lib",
4+
"eslint.validate": [
5+
"javascript",
6+
"javascriptreact",
7+
{ "language": "typescript", "autoFix": true },
8+
{ "language": "typescriptreact", "autoFix": true }
9+
]
410
}

packages/app/.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
src/app/overmind/**/*
2+
src/app/vscode/**/*

packages/app/.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"settings": {
33
"import/resolver": {
44
"webpack": {
5-
"config": "config/webpack.common.js"
5+
"config": "config/webpack.lint.js"
66
}
77
},
88
"import/external-module-folders": ["src", "node_modules"]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const config = require('./webpack.common');
2+
3+
// For linting support for importing types
4+
config.resolve.extensions.push('.d.ts');
5+
6+
module.exports = config;

packages/app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"test:watch": "jest --watch --env=jsdom",
1818
"test:integrations": "jest --config integration-tests/jest.config.json --maxWorkers=2",
1919
"lint": "npm run lint:app && npm run lint:embed",
20-
"lint:app": "cross-env LINT=1 eslint src/app",
21-
"lint:embed": "cross-env LINT=1 eslint src/embed",
20+
"lint:app": "cross-env LINT=1 eslint --ext .js,.ts,.tsx src/app",
21+
"lint:embed": "cross-env LINT=1 eslint --ext .js,.ts,.tsx src/embed",
2222
"integrations:start": "docker run -v $(pwd):/app/ -it codesandbox/test yarn start:test",
2323
"typecheck": "tsc --noEmit -p tsconfig.check.json"
2424
},

packages/app/src/app/components/CodeEditor/Configuration/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { TextOperation } from 'ot';
33
import { Module } from '@codesandbox/common/lib/types';
44
import getUI from '@codesandbox/common/lib/templates/configuration/ui';
5-
import getType from 'app/utils/get-type.ts';
5+
import getType from 'app/utils/get-type';
66
import EntryIcons from 'app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/Entry/EntryIcons';
77
import Tooltip from '@codesandbox/common/lib/components/Tooltip';
88
import { ConfigurationFile } from '@codesandbox/common/lib/templates/configuration/types';

packages/app/src/app/components/CodeEditor/MonacoDiff/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
// @flow
21
import React from 'react';
32

4-
import type { Editor, Settings } from '../types';
3+
import { Editor, Settings } from '../types';
54
import MonacoReactComponent from '../Monaco/MonacoReactComponent';
65
import defineTheme from '../Monaco/define-theme';
76

packages/app/src/app/components/CodeEditor/VSCode/Configuration/elements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import styled, { css } from 'styled-components';
1+
import styled from 'styled-components';
22

33
export const Container = styled.div`
44
padding: 1rem;

packages/app/src/app/components/CodeEditor/VSCode/Configuration/index.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import React from 'react';
2-
import { TextOperation } from 'ot';
3-
import { Module } from '@codesandbox/common/lib/types';
1+
import { ConfigurationFile } from '@codesandbox/common/lib/templates/configuration/types';
42
import getUI from '@codesandbox/common/lib/templates/configuration/ui';
5-
import getType from 'app/utils/get-type.ts';
6-
import EntryIcons from 'app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/Entry/EntryIcons';
73
import theme from '@codesandbox/common/lib/theme';
4+
import { Module } from '@codesandbox/common/lib/types';
5+
import { TextOperation } from 'ot';
6+
import React from 'react';
7+
8+
import EntryIcons from 'app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/Entry/EntryIcons';
9+
import getType from 'app/utils/get-type';
810

911
import { Props as EditorProps, Editor } from '../../types';
12+
1013
import { Container, Title, Description } from './elements';
11-
import { ConfigurationFile } from '@codesandbox/common/lib/templates/configuration/types';
1214

1315
type Disposable = {
1416
dispose: () => void;

0 commit comments

Comments
 (0)