Skip to content

Commit 6064b8d

Browse files
committed
set up TypeScript
1 parent 59d7a95 commit 6064b8d

File tree

14 files changed

+2572
-116
lines changed

14 files changed

+2572
-116
lines changed

.eslint_todo.ts

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
// This configuration was generated by `exe/eslint_autogen`
2+
// on 2025-12-16 22:19:02 UTC.
3+
// The point is for the user to remove these configuration records
4+
// one by one as the offenses are removed from the code base.
5+
6+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
7+
const eslintTodo: Record<string, unknown>[] = [
8+
{
9+
files: ["app/javascript/application.ts"],
10+
rules: {
11+
"@stylistic/comma-dangle": "off",
12+
"@stylistic/key-spacing": "off",
13+
"@stylistic/keyword-spacing": "off",
14+
"@stylistic/max-len": "off",
15+
"@stylistic/multiline-ternary": "off",
16+
"@stylistic/no-extra-parens": "off",
17+
"@stylistic/object-curly-spacing": "off",
18+
"@stylistic/quote-props": "off",
19+
"@stylistic/quotes": "off",
20+
"@stylistic/semi": "off",
21+
"@stylistic/space-before-blocks": "off",
22+
"@stylistic/space-before-function-paren": "off",
23+
"@typescript-eslint/ban-ts-comment": "off",
24+
"@typescript-eslint/explicit-function-return-type": "off",
25+
"@typescript-eslint/no-deprecated": "off",
26+
"@typescript-eslint/no-unsafe-argument": "off",
27+
"@typescript-eslint/no-unsafe-assignment": "off",
28+
"@typescript-eslint/no-unsafe-call": "off",
29+
"@typescript-eslint/no-unsafe-member-access": "off",
30+
"@typescript-eslint/no-unsafe-return": "off",
31+
"@typescript-eslint/prefer-destructuring": "off",
32+
"@typescript-eslint/prefer-nullish-coalescing": "off",
33+
"@typescript-eslint/prefer-optional-chain": "off",
34+
"@typescript-eslint/strict-boolean-expressions": "off",
35+
"camelcase": "off",
36+
"curly": "off",
37+
"eqeqeq": "off",
38+
"func-names": "off",
39+
"id-length": "off",
40+
"import/no-unresolved": "off",
41+
"max-len": "off",
42+
"max-lines": "off",
43+
"new-cap": "off",
44+
"no-plusplus": "off",
45+
"no-ternary": "off",
46+
"object-shorthand": "off",
47+
"prefer-arrow-callback": "off",
48+
"prefer-named-capture-group": "off",
49+
"prefer-template": "off",
50+
"require-unicode-regexp": "off",
51+
"sort-keys": "off",
52+
"sort-keys-fix/sort-keys-fix": "off",
53+
"vars-on-top": "off",
54+
},
55+
},
56+
{
57+
files: ["eslint.config.mts"],
58+
rules: {
59+
"@typescript-eslint/no-unsafe-assignment": "off",
60+
},
61+
},
62+
{
63+
files: ["spec/javascript/setup.ts"],
64+
rules: {
65+
"@stylistic/max-len": "off",
66+
"@stylistic/multiline-comment-style": "off",
67+
"@stylistic/object-curly-spacing": "off",
68+
"@stylistic/quotes": "off",
69+
"@typescript-eslint/ban-ts-comment": "off",
70+
"@typescript-eslint/explicit-function-return-type": "off",
71+
"@typescript-eslint/no-unsafe-assignment": "off",
72+
"@typescript-eslint/no-unsafe-call": "off",
73+
"capitalized-comments": "off",
74+
"func-names": "off",
75+
"id-length": "off",
76+
"max-len": "off",
77+
"new-cap": "off",
78+
"prefer-named-capture-group": "off",
79+
"require-unicode-regexp": "off",
80+
"sort-imports": "off",
81+
"sort-keys": "off",
82+
"sort-keys-fix/sort-keys-fix": "off",
83+
"vitest/require-hook": "off",
84+
},
85+
},
86+
{
87+
files: ["spec/javascript/spec/models/story_spec.ts"],
88+
rules: {
89+
"@stylistic/max-len": "off",
90+
"@stylistic/no-extra-parens": "off",
91+
"@stylistic/object-curly-spacing": "off",
92+
"@typescript-eslint/ban-ts-comment": "off",
93+
"@typescript-eslint/no-empty-function": "off",
94+
"@typescript-eslint/no-unsafe-assignment": "off",
95+
"@typescript-eslint/no-unsafe-call": "off",
96+
"@typescript-eslint/no-unsafe-member-access": "off",
97+
"@typescript-eslint/strict-boolean-expressions": "off",
98+
"camelcase": "off",
99+
"func-names": "off",
100+
"max-lines-per-function": "off",
101+
"no-implicit-coercion": "off",
102+
"no-multi-assign": "off",
103+
"prefer-arrow-callback": "off",
104+
"sort-imports": "off",
105+
"sort-keys": "off",
106+
"sort-keys-fix/sort-keys-fix": "off",
107+
"vitest/prefer-lowercase-title": "off",
108+
},
109+
},
110+
{
111+
files: ["spec/javascript/spec/views/story_view_spec.ts"],
112+
rules: {
113+
"@stylistic/max-len": "off",
114+
"@stylistic/multiline-ternary": "off",
115+
"@stylistic/object-curly-spacing": "off",
116+
"@typescript-eslint/ban-ts-comment": "off",
117+
"@typescript-eslint/explicit-function-return-type": "off",
118+
"@typescript-eslint/init-declarations": "off",
119+
"@typescript-eslint/no-empty-function": "off",
120+
"@typescript-eslint/no-unsafe-argument": "off",
121+
"@typescript-eslint/no-unsafe-assignment": "off",
122+
"@typescript-eslint/no-unsafe-call": "off",
123+
"@typescript-eslint/no-unsafe-member-access": "off",
124+
"camelcase": "off",
125+
"func-names": "off",
126+
"func-style": "off",
127+
"id-length": "off",
128+
"max-len": "off",
129+
"max-lines-per-function": "off",
130+
"max-statements": "off",
131+
"new-cap": "off",
132+
"no-negated-condition": "off",
133+
"no-param-reassign": "off",
134+
"no-ternary": "off",
135+
"one-var": "off",
136+
"prefer-arrow-callback": "off",
137+
"sort-imports": "off",
138+
"sort-keys": "off",
139+
"sort-keys-fix/sort-keys-fix": "off",
140+
"vars-on-top": "off",
141+
"vitest/no-hooks": "off",
142+
"vitest/prefer-lowercase-title": "off",
143+
"vitest/require-hook": "off",
144+
},
145+
},
146+
{
147+
files: ["stylelint.config.mjs"],
148+
rules: {
149+
"@stylistic/quote-props": "off",
150+
},
151+
},
152+
{
153+
files: ["vitest.config.ts"],
154+
rules: {
155+
"@stylistic/function-paren-newline": "off",
156+
"@stylistic/max-len": "off",
157+
"max-len": "off",
158+
},
159+
},
160+
];
161+
162+
export default eslintTodo;

.gitignore

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,25 @@
1313
!/log/.keep
1414
!/tmp/.keep
1515

16-
# Ignore pidfiles, but keep the directory.
17-
/tmp/pids/*
18-
!/tmp/pids/
19-
!/tmp/pids/.keep
16+
# Ignore uploaded files in development.
17+
/storage/*
18+
!/storage/.keep
2019

21-
/coverage
2220
/public/assets
21+
.byebug_history
2322

2423
# Ignore master key for decrypting credentials and more.
2524
/config/master.key
26-
2725
spec/examples.txt
26+
/coverage/*
2827

29-
# Ignore local .env files
30-
*.local
31-
.env
32-
28+
/public/packs
29+
/public/packs-test
30+
/node_modules
3331
/app/assets/builds/*
3432
!/app/assets/builds/.keep
33+
tsconfig.tsbuildinfo
34+
.eslintcache
3535

36-
/node_modules
36+
# Ignore local environment variable files.
37+
.env.*.local
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module "eslint-plugin-sort-keys-fix";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
import "jquery";
23
import "bootstrap";
34
import "mousetrap";

eslint.config.mjs

Lines changed: 0 additions & 35 deletions
This file was deleted.

eslint.config.mts

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import globals from "globals";
2+
import importPlugin from "eslint-plugin-import";
3+
import vitest from "eslint-plugin-vitest";
4+
import js from "@eslint/js";
5+
import stylistic from "@stylistic/eslint-plugin";
6+
import tseslint from "typescript-eslint";
7+
import {defineConfig} from "eslint/config";
8+
import sortKeysFix from "eslint-plugin-sort-keys-fix";
9+
import eslintTodo from "./.eslint_todo";
10+
11+
export default defineConfig([
12+
js.configs.all,
13+
tseslint.configs.all,
14+
importPlugin.flatConfigs.recommended,
15+
vitest.configs.all,
16+
stylistic.configs.all,
17+
{
18+
ignores: [
19+
".eslint_todo.ts",
20+
"app/assets/builds/**",
21+
"coverage/**",
22+
"public/**",
23+
"vendor/**",
24+
],
25+
},
26+
{
27+
files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
28+
languageOptions: {
29+
globals: globals.browser,
30+
parserOptions: {
31+
projectService: {
32+
allowDefaultProject: ["stylelint.config.mjs"],
33+
},
34+
},
35+
},
36+
plugins: {
37+
importPlugin,
38+
"sort-keys-fix": sortKeysFix,
39+
vitest,
40+
},
41+
rules: {
42+
"@stylistic/array-element-newline": ["error", "consistent"],
43+
"@stylistic/brace-style": ["error", "1tbs", {allowSingleLine: true}],
44+
"@stylistic/comma-dangle": ["error", "always-multiline"],
45+
"@stylistic/function-call-argument-newline": ["error", "consistent"],
46+
"@stylistic/indent": ["error", 2],
47+
"@stylistic/max-len": ["error", 80, {ignoreUrls: true}],
48+
"@stylistic/object-property-newline":
49+
["error", {allowAllPropertiesOnSameLine: true}],
50+
"@stylistic/padded-blocks": ["error", "never"],
51+
"@stylistic/quote-props": ["error", "as-needed", {keywords: true}],
52+
"@stylistic/space-before-function-paren":
53+
["error", {anonymous: "always", named: "never"}],
54+
"@typescript-eslint/consistent-indexed-object-style":
55+
["error", "index-signature"],
56+
"@typescript-eslint/consistent-type-assertions":
57+
["error", {assertionStyle: "never"}],
58+
"@typescript-eslint/explicit-member-accessibility": "off",
59+
"@typescript-eslint/naming-convention": "off",
60+
"@typescript-eslint/no-magic-numbers": "off",
61+
"@typescript-eslint/prefer-readonly-parameter-types": "off",
62+
"arrow-body-style": ["error", "always"],
63+
"func-style": ["error", "declaration"],
64+
"max-len": ["error", 84, {ignoreUrls: true}],
65+
"no-duplicate-imports": ["error", {allowSeparateTypeImports: true}],
66+
"no-magic-numbers": "off",
67+
"no-undefined": "off",
68+
"no-var": "off",
69+
"one-var": ["error", "never"],
70+
"sort-imports":
71+
["error", {ignoreCase: true, ignoreDeclarationSort: true}],
72+
"sort-keys": ["error", "asc", {caseSensitive: false, natural: true}],
73+
"sort-keys-fix/sort-keys-fix":
74+
["error", "asc", {caseSensitive: false, natural: true}],
75+
"vitest/consistent-test-it":
76+
["error", {fn: "it", withinDescribe: "it"}],
77+
"vitest/prefer-expect-assertions": "off",
78+
"vitest/prefer-to-be-falsy": "off",
79+
"vitest/prefer-to-be-truthy": "off",
80+
"vitest/require-top-level-describe": "off",
81+
},
82+
settings: {
83+
"import/resolver": {
84+
typescript: {
85+
alwaysTryTypes: true,
86+
},
87+
},
88+
},
89+
},
90+
{
91+
files: ["spec/javascript/setup.ts"],
92+
rules: {
93+
"vitest/no-hooks": "off",
94+
"vitest/no-standalone-expect": "off",
95+
},
96+
},
97+
{
98+
files: ["spec/javascript/support/**/*"],
99+
rules: {
100+
"vitest/no-hooks": "off",
101+
},
102+
},
103+
{
104+
files: ["app/javascript/**/*.ts"],
105+
rules: {
106+
"vitest/require-hook": "off",
107+
},
108+
},
109+
...eslintTodo,
110+
]);

0 commit comments

Comments
 (0)