Skip to content

Commit

Permalink
chore: Add linter
Browse files Browse the repository at this point in the history
  • Loading branch information
NiGhTTraX committed Jul 19, 2020
1 parent 2649bbc commit c71eb53
Show file tree
Hide file tree
Showing 24 changed files with 450 additions and 83 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: "@nighttrax/eslint-config-tsx",
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"test": "lerna run test"
},
"devDependencies": {
"@nighttrax/eslint-config-tsx": "~6.1.0",
"eslint": "~7.5.0",
"lerna": "~3.14.0",
"typescript": "~3.9.6"
}
Expand Down
3 changes: 2 additions & 1 deletion packages/bar/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { meaningOfLife } from '@nighttrax/foo';
import { meaningOfLife } from "@nighttrax/foo";

// eslint-disable-next-line no-console
console.log(meaningOfLife);
7 changes: 6 additions & 1 deletion packages/components/src/button.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import React from "react";

export const Button = () => <button onClick={() => alert('you clicked me')}>Click me</button>;
export const Button = () => (
// eslint-disable-next-line no-alert
<button type="button" onClick={() => alert("you clicked me")}>
Click me
</button>
);
3 changes: 3 additions & 0 deletions packages/cra-ejected-babel/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
config/
scripts/
src/react-app-env.d.ts
3 changes: 0 additions & 3 deletions packages/cra-ejected-babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@
"build": "node scripts/build.js",
"test": "yarn run build"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
Expand Down
8 changes: 4 additions & 4 deletions packages/cra-ejected-babel/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import ReactDOM from "react-dom";
import {meaningOfLife} from "@nighttrax/foo";
import {Button} from "@nighttrax/components";
import { meaningOfLife } from "@nighttrax/foo";
import { Button } from "@nighttrax/components";

ReactDOM.render(
<React.StrictMode>
{meaningOfLife}
<Button/>
<Button />
</React.StrictMode>,
document.getElementById('root')
document.getElementById("root")
);
3 changes: 2 additions & 1 deletion packages/cra/config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
/* eslint-disable import/no-extraneous-dependencies */
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");

module.exports = (config) => {
// Remove the ModuleScopePlugin which throws when we try to import something
Expand Down
3 changes: 0 additions & 3 deletions packages/cra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
"build": "SKIP_PREFLIGHT_CHECK=true react-app-rewired build",
"test": "yarn run build"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
Expand Down
8 changes: 4 additions & 4 deletions packages/cra/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import ReactDOM from "react-dom";
import {meaningOfLife} from "@nighttrax/foo";
import {Button} from "@nighttrax/components";
import { meaningOfLife } from "@nighttrax/foo";
import { Button } from "@nighttrax/components";

ReactDOM.render(
<React.StrictMode>
{meaningOfLife}
<Button/>
<Button />
</React.StrictMode>,
document.getElementById('root')
document.getElementById("root")
);
1 change: 0 additions & 1 deletion packages/foo/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export const meaningOfLife = 42;

25 changes: 14 additions & 11 deletions packages/jest-babel/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
module.exports = {
"presets": [
['@babel/preset-env', {targets: {node: 'current'}}],
"@babel/preset-typescript"
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
"@babel/preset-typescript",
],

"plugins": [
["module-resolver", {
"alias": {
"^@nighttrax/(.+)": "../\\1/src"
}
}]
]
}
plugins: [
[
"module-resolver",
{
alias: {
"^@nighttrax/(.+)": "../\\1/src",
},
},
],
],
};
2 changes: 1 addition & 1 deletion packages/jest-babel/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {meaningOfLife} from "@nighttrax/foo";
import { meaningOfLife } from "@nighttrax/foo";

export const whatIsTheMeaningOfLife = () => meaningOfLife;
6 changes: 3 additions & 3 deletions packages/jest-babel/test/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {whatIsTheMeaningOfLife} from "../src";
import { whatIsTheMeaningOfLife } from "../src";

describe("meaning of life", function() {
it("should be 42", function() {
describe("meaning of life", () => {
it("should be 42", () => {
expect(whatIsTheMeaningOfLife()).toEqual(42);
});
});
13 changes: 7 additions & 6 deletions packages/jest-tsjest/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const { pathsToModuleNameMapper } = require('ts-jest/utils');
/* eslint-disable import/no-extraneous-dependencies */
const { pathsToModuleNameMapper } = require("ts-jest/utils");
// Load the config which holds the path aliases.
const { compilerOptions } = require('../../tsconfig.json');
const { compilerOptions } = require("../../tsconfig.json");

module.exports = {
preset: 'ts-jest',
preset: "ts-jest",

moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths , {
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
// This has to match the baseUrl defined in tsconfig.json.
prefix: '<rootDir>/../../'
})
prefix: "<rootDir>/../../",
}),
};
2 changes: 1 addition & 1 deletion packages/jest-tsjest/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {meaningOfLife} from "@nighttrax/foo";
import { meaningOfLife } from "@nighttrax/foo";

export const whatIsTheMeaningOfLife = () => meaningOfLife;
6 changes: 3 additions & 3 deletions packages/jest-tsjest/test/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {whatIsTheMeaningOfLife} from "../src";
import { whatIsTheMeaningOfLife } from "../src";

describe("meaning of life", function() {
it("should be 42", function() {
describe("meaning of life", () => {
it("should be 42", () => {
expect(whatIsTheMeaningOfLife()).toEqual(42);
});
});
7 changes: 4 additions & 3 deletions packages/nextjs/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const withTM = require('next-transpile-modules')(
// List all of your dependencies.
['components']
/* eslint-disable import/no-extraneous-dependencies */
const withTM = require("next-transpile-modules")(
// List all of your dependencies.
["components"]
);

module.exports = withTM();
14 changes: 8 additions & 6 deletions packages/nextjs/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from "react";
import {meaningOfLife} from "@nighttrax/foo";
import {Button} from "@nighttrax/components";
import { meaningOfLife } from "@nighttrax/foo";
import { Button } from "@nighttrax/components";

export default () => <div>
<p>Meaning of life is {meaningOfLife}</p>
<Button/>
</div>;
export default () => (
<div>
<p>Meaning of life is {meaningOfLife}</p>
<Button />
</div>
);
3 changes: 2 additions & 1 deletion packages/ts-node/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {meaningOfLife} from "@nighttrax/foo";
import { meaningOfLife } from "@nighttrax/foo";

// eslint-disable-next-line no-console
console.log(meaningOfLife);
2 changes: 1 addition & 1 deletion packages/webpack/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import '@nighttrax/bar';
import "@nighttrax/bar";
15 changes: 7 additions & 8 deletions packages/webpack/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
/* eslint-disable import/no-extraneous-dependencies */
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");

module.exports = {
entry: "./src/index.ts",
mode: 'development',
mode: "development",
output: {
filename: "bundle.js"
filename: "bundle.js",
},
resolve: {
extensions: [".ts", ".tsx", ".js"],
plugins: [new TsconfigPathsPlugin()]
plugins: [new TsconfigPathsPlugin()],
},
module: {
rules: [
{ test: /\.tsx?$/, loader: "ts-loader" }
]
}
rules: [{ test: /\.tsx?$/, loader: "ts-loader" }],
},
};
Loading

0 comments on commit c71eb53

Please sign in to comment.