@mlaursen/eslint-config 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.github ADDED
@@ -0,0 +1 @@
1
+ GITHUB_TOKEN=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
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [1.5.0](https://github.com/mlaursen/eslint-config/compare/v1.4.0...v1.5.0) (2022-03-09)
6
+
7
+
8
+ ### Features
9
+
10
+ * force braces ([f6d3f69](https://github.com/mlaursen/eslint-config/commit/f6d3f69cb8644746f7db8e6d562fbdd3a20c8d19))
11
+ * Force consistent type imports for typescript 3.8 or greater ([880217f](https://github.com/mlaursen/eslint-config/commit/880217fb7ad258acc6601218bb649c0928d97ade))
12
+ * Upgrade eslint dependencies to latest ([7551d04](https://github.com/mlaursen/eslint-config/commit/7551d0457be41ca3844a35b45a1eb11b9a510ffc))
13
+
5
14
  ## [1.4.0](https://github.com/mlaursen/eslint-config/compare/v1.3.0...v1.4.0) (2022-01-11)
6
15
 
7
16
 
package/index.js CHANGED
@@ -2,11 +2,21 @@ const confusingBrowserGlobals = require('confusing-browser-globals');
2
2
 
3
3
  let react = false;
4
4
  let isNewJsx = false;
5
+ let isTypescript38 = false;
5
6
  try {
6
7
  require.resolve('react');
7
8
  react = true;
8
9
  isNewJsx = parseInt(require('react').version, 10) > 16;
9
10
  } catch (e) {}
11
+ try {
12
+ const { version } = require('typescript');
13
+ const [majorString, minorString] = version.split('.');
14
+ const major = parseInt(majorString, 10);
15
+ const minor = parseInt(minorString, 10);
16
+ if (!Number.isNaN(major) && !Number.isNaN(minor)) {
17
+ isTypescript38 = major > 3 || (major === 3 && minor > 8);
18
+ }
19
+ } catch (e) {}
10
20
 
11
21
  module.exports = {
12
22
  parser: '@typescript-eslint/parser',
@@ -54,6 +64,8 @@ module.exports = {
54
64
 
55
65
  // too many false positives with aliases/root dirs
56
66
  'import/no-unresolved': 0,
67
+
68
+ curly: 'error',
57
69
  },
58
70
  overrides: [
59
71
  {
@@ -104,6 +116,10 @@ module.exports = {
104
116
  varsIgnorePattern: '^_',
105
117
  },
106
118
  ],
119
+
120
+ '@typescript-eslint/consistent-type-imports': isTypescript38
121
+ ? ['error']
122
+ : 'off',
107
123
  },
108
124
  },
109
125
  {
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@mlaursen/eslint-config",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "An eslint config used by mlaursen for most projects.",
5
5
  "main": "index.js",
6
6
  "repository": "https://github.com/mlaursen/eslint-config.git",
7
7
  "author": "Mikkel Laursen <mlaursen03@gmail.com>",
8
8
  "license": "MIT",
9
9
  "scripts": {
10
+ "test": "eslint -c index.js \"test/**/*.{js,jsx,ts,tsx}\"",
10
11
  "run-script": "ts-node -T -P tsconfig.node.json",
11
12
  "release": "yarn run-script scripts/release.ts"
12
13
  },
@@ -18,27 +19,28 @@
18
19
  "typescript"
19
20
  ],
20
21
  "dependencies": {
21
- "@typescript-eslint/eslint-plugin": "^5.9.1",
22
- "@typescript-eslint/parser": "^5.9.1",
22
+ "@typescript-eslint/eslint-plugin": "^5.14.0",
23
+ "@typescript-eslint/parser": "^5.14.0",
23
24
  "confusing-browser-globals": "^1.0.11",
24
- "eslint-config-prettier": "^8.2.0",
25
+ "eslint-config-prettier": "^8.5.0",
25
26
  "eslint-plugin-import": "^2.25.4",
26
- "eslint-plugin-jest": "^25.3.4",
27
+ "eslint-plugin-jest": "^26.1.1",
27
28
  "eslint-plugin-jsx-a11y": "^6.5.1",
28
- "eslint-plugin-react": "^7.28.0",
29
+ "eslint-plugin-react": "^7.29.3",
29
30
  "eslint-plugin-react-hooks": "^4.3.0",
30
31
  "eslint-plugin-tsdoc": "^0.2.14"
31
32
  },
32
33
  "devDependencies": {
33
34
  "@mlaursen/changelog-preset": "^1.1.0",
34
35
  "@octokit/core": "^3.5.1",
35
- "@types/inquirer": "^8.1.3",
36
- "@types/node": "^17.0.8",
37
- "dotenv": "^11.0.0",
38
- "inquirer": "^8.2.0",
36
+ "@types/inquirer": "^8.2.0",
37
+ "@types/node": "^17.0.21",
38
+ "dotenv": "^16.0.0",
39
+ "eslint": "^8.10.0",
40
+ "inquirer": "^8.2.1",
39
41
  "standard-version": "^9.3.2",
40
- "ts-node": "^10.4.0",
41
- "typescript": "^4.5.4"
42
+ "ts-node": "^10.7.0",
43
+ "typescript": "^4.6.2"
42
44
  },
43
45
  "peerDependencies": {
44
46
  "eslint": ">= 8.0.0",
package/.prettierrc DELETED
@@ -1,9 +0,0 @@
1
- printWidth: 80
2
- trailingComma: es5
3
- overrides:
4
- - files: "*.{js,jsx,scss}"
5
- options:
6
- singleQuote: true
7
- - files: "*.md"
8
- options:
9
- proseWrap: always
package/.versionrc.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('@mlaursen/changelog-preset');
@@ -1,28 +0,0 @@
1
- const packageJson = require('./package.json');
2
- const {
3
- createConfig,
4
- defaultGetCommitType,
5
- } = require('@mlaursen/changelog-preset/createConfig');
6
-
7
- module.exports = createConfig({
8
- tokens: Array.from(
9
- new Set([
10
- ...Object.keys(packageJson.dependencies),
11
- ...Object.keys(packageJson.devDependencies),
12
- ])
13
- ),
14
- ignoreDeps: false,
15
- getCommitType: (commit) => {
16
- const { scope = '' } = commit;
17
- if (scope === 'deps') {
18
- return 'Dependencies';
19
- }
20
-
21
- if (scope === 'dev-deps') {
22
- // don't include dev-deps
23
- return '';
24
- }
25
-
26
- return defaultGetCommitType(commit);
27
- },
28
- });
@@ -1,142 +0,0 @@
1
- import { Octokit } from "@octokit/core";
2
- import { execSync } from "child_process";
3
- import dotenv from "dotenv";
4
- import inquirer from "inquirer";
5
- import { readFileSync } from "node:fs";
6
- import { join } from "node:path";
7
-
8
- function loggedCommand(command: string): void {
9
- console.log(command);
10
- execSync(command, { stdio: "inherit" });
11
- console.log("");
12
- }
13
-
14
- function undo(version?: string): void {
15
- loggedCommand("git reset HEAD^");
16
- if (typeof version === "string") {
17
- loggedCommand(`git tag -d v${version}`);
18
- }
19
- }
20
-
21
- const NEW_ENTRY = /^#{1,3}\s+\[\d/;
22
-
23
- async function getReleaseNotes(version: string): Promise<string> {
24
- console.log("Update the CHANGELOG.md with any additional changes.");
25
- const { confirmed } = await inquirer.prompt<{ confirmed: boolean }>([
26
- {
27
- type: "confirm",
28
- name: "confirmed",
29
- message: "Continue the release?",
30
- },
31
- ]);
32
- if (!confirmed) {
33
- console.error("Canceling the release.");
34
- undo(version);
35
-
36
- process.exit(1);
37
- }
38
-
39
- const changelog = readFileSync(join(process.cwd(), "CHANGELOG.md"), "utf8");
40
- const lines = changelog.split(/\r?\n/);
41
- let lastEntryStart = -1;
42
- let nextEntryStart = -1;
43
-
44
- for (let i = 0; i < lines.length; i += 1) {
45
- if (NEW_ENTRY.test(lines[i])) {
46
- if (lastEntryStart === -1) {
47
- lastEntryStart = i + 1;
48
- } else if (nextEntryStart === -1) {
49
- nextEntryStart = i;
50
- break;
51
- }
52
- }
53
- }
54
-
55
- if (lastEntryStart === -1 || nextEntryStart === -1) {
56
- console.error("Unable to find a release block.");
57
- process.exit(1);
58
- }
59
-
60
- return lines.slice(lastEntryStart, nextEntryStart).join("\n");
61
- }
62
-
63
- const RELEASE_TYPES = ["major", "minor", "patch"];
64
-
65
- async function run(): Promise<void> {
66
- let type = "";
67
- let prerelease = "";
68
- for (let i = 0; i < process.argv.length; i += 1) {
69
- const flag = process.argv[i];
70
- const value = process.argv[i + 1];
71
- if (
72
- flag === "-t" &&
73
- typeof value === "string" &&
74
- RELEASE_TYPES.includes(value)
75
- ) {
76
- type = ` --release-as ${value}`;
77
- } else if (flag === "-p" || flag === "--prerelease") {
78
- prerelease = " --prerelease";
79
- }
80
- }
81
-
82
- const githubDotEnv = join(process.cwd(), ".env.github");
83
- dotenv.config({ path: githubDotEnv });
84
-
85
- const { GITHUB_TOKEN } = process.env;
86
- if (!GITHUB_TOKEN) {
87
- console.error(
88
- `Missing a \`GITHUB_TOKEN\` environment variable. This should be located at:
89
- - ${githubDotEnv}
90
-
91
- A token can be created at:
92
- - https://github.com/settings/tokens/new?scopes=repo
93
- `
94
- );
95
-
96
- process.exit(1);
97
- }
98
-
99
- loggedCommand(`yarn standard-version${type}${prerelease}`);
100
-
101
- const { version } = JSON.parse(
102
- readFileSync(join(process.cwd(), "package.json"), "utf8")
103
- );
104
- if (typeof version !== "string") {
105
- console.error("Unable to get the package version.");
106
- undo();
107
- process.exit(1);
108
- }
109
-
110
- const releaseNotes = await getReleaseNotes(version);
111
- const { confirmed } = await inquirer.prompt<{ confirmed: boolean }>([
112
- {
113
- type: "confirm",
114
- name: "confirmed",
115
- message: `Open the authenticator app to get a one-time password and run the following command:
116
-
117
- npm publish --otp
118
- `,
119
- },
120
- ]);
121
- if (!confirmed) {
122
- console.error("Canceling the release.");
123
- undo(version);
124
-
125
- process.exit(1);
126
- }
127
- loggedCommand("git push --follow-tags origin main");
128
- const octokit = new Octokit({ auth: GITHUB_TOKEN });
129
- const response = await octokit.request(
130
- "POST /repos/{owner}/{repo}/releases",
131
- {
132
- owner: "mlaursen",
133
- repo: "eslint-config",
134
- tag_name: `v${version}`,
135
- body: releaseNotes,
136
- }
137
- );
138
-
139
- console.log(`Created release: ${response.data.html_url}`);
140
- }
141
-
142
- run();
package/tsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "module": "commonjs",
5
- "strict": true,
6
- "declaration": true,
7
- "esModuleInterop": true,
8
- "moduleResolution": "node",
9
- "resolveJsonModule": true,
10
- "noFallthroughCasesInSwitch": true,
11
- "allowSyntheticDefaultImports": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "lib": [
14
- "dom",
15
- "dom.iterable",
16
- "esnext"
17
- ]
18
- }
19
- }
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "jsx": "react-jsx",
5
- "target": "es5",
6
- "module": "commonjs",
7
- "skipLibCheck": false,
8
- "isolatedModules": false
9
- }
10
- }