Skip to content

Commit

Permalink
lint and tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
adiun committed Jun 26, 2021
1 parent e3cbb82 commit b03a15e
Show file tree
Hide file tree
Showing 22 changed files with 11,823 additions and 690 deletions.
44 changes: 44 additions & 0 deletions app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const scaffold = require("@adiun/vm-scaffold/.eslintrc.ui");

// https://github.com/dotansimha/graphql-eslint/tree/master/docs
const graphqlRules = {
"@typescript-eslint/naming-convention": "off",
"unicorn/filename-case": "off",
"@graphql-eslint/avoid-duplicate-fields": "error",
"@graphql-eslint/fields-on-correct-type": "error",
"@graphql-eslint/known-argument-names": "error",
"@graphql-eslint/known-type-names": "error",
"@graphql-eslint/no-undefined-variables": "error",
"@graphql-eslint/no-unreachable-types": "error",
"@graphql-eslint/no-unused-variables": "error",
"@graphql-eslint/unique-variable-names": "error",
"@graphql-eslint/provided-required-arguments": "error",
"@graphql-eslint/value-literals-of-correct-type": "error",
"@graphql-eslint/variables-are-input-types": "error",
"@graphql-eslint/variables-in-allowed-position": "error",
};

module.exports = {
...scaffold,
overrides: [
{
files: ["*.tsx", "*.ts", "*.jsx", "*.js"],
processor: "@graphql-eslint/graphql",
rules: graphqlRules,
},
{
files: ["*.graphql"],
parser: "@graphql-eslint/eslint-plugin",
plugins: ["@graphql-eslint"],
rules: {
// NOTE: Prettier is disabled within GraphQL snippets.
"prettier/prettier": "off",
...graphqlRules,
},
},
],
parserOptions: {
...scaffold.parserOptions,
project: "./tsconfig.json",
},
};
5 changes: 5 additions & 0 deletions app/.stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const scaffoldConfig = require("@adiun/vm-scaffold/.stylelintrc");

module.exports = {
...scaffoldConfig,
};
22 changes: 22 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "0.1.0",
"scripts": {
"build": "vite build",
"lint:eslint": "eslint ./src --ext js,ts,tsx --max-warnings 0",
"lint:stylelint": "stylelint '**/*.ts[x]'",
"lint": "npm-run-all --parallel lint:eslint lint:stylelint",
"serve": "vite preview",
"start": "vite",
"test": "tsc"
Expand All @@ -13,6 +16,25 @@
"react-dom": "17.0.2"
},
"devDependencies": {
"@graphql-eslint/eslint-plugin": "1.1.0",
"@microsoft/eslint-plugin-sdl": "0.1.6",
"@typescript-eslint/eslint-plugin": "4.9.1",
"@typescript-eslint/parser": "4.9.1",
"eslint-config-prettier": "6.15.0",
"eslint-import-resolver-typescript": "2.4.0",
"eslint-plugin-functional": "3.1.0",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-json-files": "1.1.0",
"eslint-plugin-mui-unused-classes": "1.0.3",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-react": "7.24.0",
"eslint-plugin-react-hooks": "4.2.0",
"eslint-plugin-simple-import-sort": "7.0.0",
"eslint-plugin-testing-library": "4.6.0",
"eslint-plugin-unicorn": "23.0.0",
"prettier": "2.3.0",
"stylelint": "13.13.1",
"stylelint-config-idiomatic-order": "8.1.0",
"@types/node": "15.12.4",
"@types/react": "17.0.11",
"@types/react-dom": "17.0.8",
Expand Down
1 change: 0 additions & 1 deletion app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { TestCoreComponent } from "@adiun/vm-coreui";

function App(): JSX.Element {
Expand Down
5 changes: 2 additions & 3 deletions app/src/define.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

// sync with vite.config.ts define settings
type PkgJson = { name: string, version: string; };
declare var pkgJson: PkgJson;
type PkgJson = { readonly name: string; readonly version: string };
declare let pkgJson: PkgJson;
15 changes: 8 additions & 7 deletions app/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import { StrictMode } from "react";
import ReactDOM from "react-dom";

import App from "./App";

ReactDOM.render(
<React.StrictMode>
<StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
)
</StrictMode>,
document.querySelector("#root")
);
18 changes: 2 additions & 16 deletions app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
{
"extends": "@adiun/vm-scaffold/tsconfig.ui.json",
"compilerOptions": {
"allowJs": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop": false,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"module": "esnext",
"moduleResolution": "Node",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": false,
"strict": true,
"target": "ESNext",
"types": ["vite/client"]
// types for import.meta.env
"rootDir": "src"
}
}
6 changes: 5 additions & 1 deletion app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { defineConfig } from "vite";
import reactRefresh from "@vitejs/plugin-react-refresh";
import { defineConfig } from "vite";

import { name, version } from "./package.json";

export default defineConfig({
plugins: [reactRefresh()],
define: {
pkgJson: { name, version },
},
esbuild: {
jsxInject: `import React from 'react'`,
},
server: {
open: true,
},
Expand Down
9 changes: 9 additions & 0 deletions coreui/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const scaffold = require("@adiun/vm-scaffold/.eslintrc.ui")

module.exports = {
...scaffold,
parserOptions: {
...scaffold.parserOptions,
project: "./tsconfig.json",
},
}
5 changes: 5 additions & 0 deletions coreui/.stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const scaffoldConfig = require("@adiun/vm-scaffold/.stylelintrc");

module.exports = {
...scaffoldConfig,
};
21 changes: 21 additions & 0 deletions coreui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,30 @@
},
"scripts": {
"build": "vite build",
"lint:eslint": "eslint ./src --ext js,ts,tsx --max-warnings 0",
"lint:stylelint": "stylelint '**/*.ts[x]'",
"lint": "npm-run-all --parallel lint:eslint lint:stylelint",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"@microsoft/eslint-plugin-sdl": "0.1.6",
"@typescript-eslint/eslint-plugin": "4.9.1",
"@typescript-eslint/parser": "4.9.1",
"eslint-config-prettier": "6.15.0",
"eslint-import-resolver-typescript": "2.4.0",
"eslint-plugin-functional": "3.1.0",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-json-files": "1.1.0",
"eslint-plugin-mui-unused-classes": "1.0.3",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-react": "7.24.0",
"eslint-plugin-react-hooks": "4.2.0",
"eslint-plugin-simple-import-sort": "7.0.0",
"eslint-plugin-testing-library": "4.6.0",
"eslint-plugin-unicorn": "23.0.0",
"prettier": "2.3.0",
"stylelint": "13.13.1",
"stylelint-config-idiomatic-order": "8.1.0",
"@types/node": "15.12.4",
"@types/react": "17.0.11",
"@types/react-dom": "17.0.8",
Expand Down
10 changes: 3 additions & 7 deletions coreui/src/components/TestCoreComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import React from 'react';

export const TestCoreComponent = () => {
return (
<div>Core UI component</div>
)
}
export const TestCoreComponent = (): JSX.Element => {
return <div>Core UI component</div>;
};
14 changes: 2 additions & 12 deletions coreui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
{
"extends": "../scaffold/tsconfig.common.json",
"extends": "@adiun/vm-scaffold/tsconfig.ui.json",
"compilerOptions": {
"allowJs": false,
"declarationDir": "lib",
"isolatedModules": true,
"jsx": "react-jsx",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"module": "esnext",
"noEmit": true,
"resolveJsonModule": true,
"rootDir": "src",
"skipLibCheck": false,
"target": "ESNext",
"types": ["vite/client"]
"rootDir": "src"
},
"include": ["src"]
}
3 changes: 3 additions & 0 deletions coreui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export default defineConfig({
},
},
},
esbuild: {
jsxInject: `import React from 'react'`,
},
plugins: [
reactRefresh(),
{
Expand Down
Loading

0 comments on commit b03a15e

Please sign in to comment.