Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ jobs:
name: Typescript
command: yarn tscheck

- run:
name: Find Unused ESLint Rules
command: yarn eslint_find_unused_rules

- run:
name: ESLint
command: yarn eslint

- run:
name: Verify ESLint Autogen
command: bundle exec exe/eslint_autogen

- run:
name: Brakeman
command: bundle exec brakeman
Expand All @@ -97,6 +109,10 @@ jobs:
name: Stylelint
command: yarn stylelint

- run:
name: Verify Stylelint Autogen
command: bundle exec exe/stylelint_autogen

- run:
name: Rubocop
command: bundle exec rubocop
Expand Down
30 changes: 30 additions & 0 deletions .eslint_todo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// This configuration was generated by `exe/eslint_autogen`
// on 2026-02-13 01:42:32 UTC.
// The point is for the user to remove these configuration records
// one by one as the offenses are removed from the code base.

import type {Linter} from "eslint";

const config: Linter.Config[] = [
// Offense count: 2
{
files: [
"app/javascript/channels/consumer.ts",
],
rules: {
"@stylistic/object-curly-spacing": "off",
},
},
// Offense count: 8
{
files: [
"app/javascript/application.ts",
"app/javascript/channels/consumer.ts",
],
rules: {
"@stylistic/semi": "off",
},
},
];

export default config;
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ spec/examples.txt
yarn-debug.log*
.yarn-integrity
tsconfig.tsbuildinfo
.eslintcache
12 changes: 6 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400`
# on 2026-01-30 16:49:19 UTC using RuboCop version 1.84.0.
# on 2026-02-13 04:04:38 UTC using RuboCop version 1.84.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -36,7 +36,7 @@ Layout/SingleLineBlockChain:
Exclude:
- 'spec/controllers/accounts_controller_spec.rb'

# Offense count: 260
# Offense count: 247
# Configuration parameters: Only, Ignore.
Lint/ConstantResolution:
Exclude:
Expand All @@ -62,8 +62,6 @@ Lint/ConstantResolution:
- 'bin/setup'
- 'bin/spring'
- 'bin/update'
- 'bin/webpack'
- 'bin/webpack-dev-server'
- 'bin/yarn'
- 'config.ru'
- 'config/application.rb'
Expand All @@ -89,6 +87,7 @@ Lint/ConstantResolution:
- 'db/migrate/20211230183931_add_service_name_to_active_storage_blobs.active_storage.rb'
- 'db/migrate/20211230183932_create_active_storage_variant_records.active_storage.rb'
- 'db/migrate/20211230183933_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb'
- 'exe/eslint_autogen'
- 'exe/stylelint_autogen'
- 'lib/route_constraints/admin_constraint.rb'
- 'spec/channels/application_cable/channel_spec.rb'
Expand Down Expand Up @@ -126,7 +125,7 @@ Lint/ConstantResolution:
# Offense count: 1
# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
# AllowedMethods: call
# WaywardPredicates: nonzero?
# WaywardPredicates: infinite?, nonzero?
Naming/PredicateMethod:
Exclude:
- 'app/models/nulls/null_user.rb'
Expand Down Expand Up @@ -176,12 +175,13 @@ Style/GlobalStdStream:
Exclude:
- 'config/environments/production.rb'

# Offense count: 5
# Offense count: 8
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: brackets, fetch
Style/HashLookupMethod:
Exclude:
- 'exe/eslint_autogen'
- 'exe/stylelint_autogen'
- 'spec/support/capybara.rb'

Expand Down
2 changes: 1 addition & 1 deletion .stylelint_todo.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This configuration was generated by `exe/stylelint_autogen`
# on 2022-03-22 16:32:46 UTC.
# on 2026-02-13 04:04:09 UTC.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.

Expand Down
110 changes: 110 additions & 0 deletions eslint.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import globals from "globals";
import importPlugin from "eslint-plugin-import";
import vitest from "eslint-plugin-vitest";
import js from "@eslint/js";
import stylistic from "@stylistic/eslint-plugin";
import tseslint from "typescript-eslint";
import {defineConfig} from "eslint/config";
import sortKeysFix from "eslint-plugin-sort-keys-fix";
import eslintTodo from "./.eslint_todo";

export default defineConfig([
js.configs.all,
tseslint.configs.all,
importPlugin.flatConfigs.recommended,
vitest.configs.all,
stylistic.configs.all,
{
ignores: [
".eslint_todo.ts",
"app/assets/builds/**",
"app/assets/config/**",
"coverage/**",
"public/**",
"vendor/**",
],
},
{
files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
languageOptions: {
globals: globals.browser,
parserOptions: {
projectService: {
allowDefaultProject: ["stylelint.config.mjs"],
},
},
},
plugins: {
importPlugin,
"sort-keys-fix": sortKeysFix,
vitest,
},
rules: {
"@stylistic/array-element-newline": ["error", "consistent"],
"@stylistic/brace-style": ["error", "1tbs", {allowSingleLine: true}],
"@stylistic/comma-dangle": ["error", "always-multiline"],
"@stylistic/function-call-argument-newline": ["error", "consistent"],
"@stylistic/indent": ["error", 2],
"@stylistic/max-len": ["error", 80, {ignoreUrls: true}],
"@stylistic/object-property-newline":
["error", {allowAllPropertiesOnSameLine: true}],
"@stylistic/padded-blocks": ["error", "never"],
"@stylistic/quote-props": ["error", "as-needed", {keywords: true}],
"@stylistic/space-before-function-paren":
["error", {anonymous: "always", named: "never"}],
"@typescript-eslint/consistent-indexed-object-style":
["error", "index-signature"],
"@typescript-eslint/consistent-type-assertions":
["error", {assertionStyle: "never"}],
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-magic-numbers": "off",
"@typescript-eslint/prefer-readonly-parameter-types": "off",
"arrow-body-style": ["error", "always"],
"func-style": ["error", "declaration"],
"max-len": ["error", 84, {ignoreUrls: true}],
"no-duplicate-imports": ["error", {allowSeparateTypeImports: true}],
"no-magic-numbers": "off",
"no-undefined": "off",
"one-var": ["error", "never"],
"sort-imports":
["error", {ignoreCase: true, ignoreDeclarationSort: true}],
"sort-keys": ["error", "asc", {caseSensitive: false, natural: true}],
"sort-keys-fix/sort-keys-fix":
["error", "asc", {caseSensitive: false, natural: true}],
"vitest/consistent-test-it":
["error", {fn: "it", withinDescribe: "it"}],
"vitest/prefer-expect-assertions": "off",
"vitest/prefer-to-be-falsy": "off",
"vitest/prefer-to-be-truthy": "off",
"vitest/require-top-level-describe": "off",
},
settings: {
"import/resolver": {
typescript: {
alwaysTryTypes: true,
},
},
},
},
{
files: ["spec/javascript/test_helper.ts"],
rules: {
"vitest/no-hooks": "off",
"vitest/no-standalone-expect": "off",
},
},
{
files: ["spec/javascript/support/**/*"],
rules: {
"vitest/no-hooks": "off",
},
},
{
files: ["app/javascript/**/*.ts"],
rules: {
"vitest/require-hook": "off",
},
},
...eslintTodo,
]);
58 changes: 58 additions & 0 deletions exe/eslint_autogen
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "active_support/all"
require "stringio"

TODO_FILE_PATH = "./.eslint_todo.ts"
HEADING = <<~COMMENTS.freeze
// This configuration was generated by `exe/eslint_autogen`
// on #{Time.now.utc}.
// The point is for the user to remove these configuration records
// one by one as the offenses are removed from the code base.
COMMENTS

File.write(TODO_FILE_PATH, "export default []")
json = `yarn --silent eslint --format json`
results = JSON.parse(json)

by_rule =
results.each_with_object({}) do |result, hash|
result.fetch("messages").each do |message|
rule_id = message.fetch("ruleId")
next if rule_id.nil?

hash[rule_id] ||= []
hash[rule_id] << result.fetch("filePath")
end
end

output = StringIO.new
output.puts(HEADING)
output.puts
output.puts("import type {Linter} from \"eslint\";")
output.puts
output.puts("const config: Linter.Config[] = [")

by_rule.sort.each do |rule, file_paths|
output.puts(" // Offense count: #{file_paths.length}")
output.puts(" {")
output.puts(" files: [")

file_paths.uniq.sort.each do |file_path|
relative_path = file_path.sub("#{Dir.pwd}/", "")
output.puts(" \"#{relative_path}\",")
end

output.puts(" ],")
output.puts(" rules: {")
output.puts(" \"#{rule}\": \"off\",")
output.puts(" },")
output.puts(" },")
end

output.puts("];")
output.puts
output.puts("export default config;")

File.write(TODO_FILE_PATH, output.string)
4 changes: 3 additions & 1 deletion exe/stylelint_autogen
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

require "active_support/all"
require "stringio"

TODO_FILE_PATH = "./.stylelint_todo.yml"
HEADING = <<~COMMENTS.freeze
Expand All @@ -12,7 +13,8 @@ HEADING = <<~COMMENTS.freeze
COMMENTS

File.write(TODO_FILE_PATH, "{}")
json = `yarn --silent stylelint --formatter json 2>&1`
json =
`yarn --silent stylelint --quiet-deprecation-warnings --formatter json 2>&1`
results = JSON.parse(json)

by_rule =
Expand Down
16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,32 @@
"postcss": "dep of stylelint-config-standard-scss, can maybe remove later"
},
"devDependencies": {
"@eslint/eslintrc": "^3.3.3",
"@eslint/js": "^9.39.2",
"@stylistic/eslint-plugin": "^5.7.0",
"@types/rails__actioncable": "^6.1.11",
"esbuild": "^0.25.0",
"eslint": "^9.39.2",
"eslint-find-rules": "^5.0.0",
"eslint-import-resolver-typescript": "^4.4.4",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"eslint-plugin-vitest": "^0.5.4",
"jiti": "^2.6.1",
"postcss": "^8.5.6",
"stylelint": "^17.0.0",
"stylelint-config-property-sort-order-smacss": "^11.0.0",
"stylelint-config-standard-scss": "^17.0.0",
"stylelint-selector-bem-pattern": "^4.0.1",
"typescript": "^5.8.3"
"typescript": "^5.8.3",
"typescript-eslint": "^8.55.0"
},
"scripts": {
"build": "esbuild app/javascript/application.ts --bundle --sourcemap --format=iife --outdir=app/assets/builds --public-path=/assets",
"build:watch": "esbuild app/javascript/application.js --bundle --sourcemap --format=iife --outdir=app/assets/builds --public-path=/assets --watch",
"eslint": "eslint ./ --cache --max-warnings=0",
"eslint_find_unused_rules": "eslint-find-rules --unused --flatConfig --no-core eslint.config.mts",
"pretest": "yarn tscheck && yarn eslint",
"stylelint": "./node_modules/stylelint/bin/stylelint.mjs 'app/assets/stylesheets/**/*'",
"tscheck": "yarn tsc --noEmit"
}
Expand Down
5 changes: 5 additions & 0 deletions types/eslint-plugin-sort-keys-fix.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module "eslint-plugin-sort-keys-fix" {
import type {ESLint} from "eslint";
const plugin: ESLint.Plugin;
export default plugin;
}
Loading