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
8 changes: 8 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import tseslint from 'typescript-eslint'
import prettier from 'eslint-config-prettier'
import checkFile from 'eslint-plugin-check-file'

export default tseslint.config(
{ignores: ['node_modules', 'dist', 'coverage', '.vitest']},
Expand All @@ -18,4 +19,11 @@ export default tseslint.config(
],
},
},
{
files: ['src/**/*.ts', 'tests/**/*.ts'],
plugins: {'check-file': checkFile},
rules: {
'check-file/filename-naming-convention': ['error', {'**/*.ts': 'KEBAB_CASE'}, {ignoreMiddleExtensions: true}],
},
},
)
110 changes: 110 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@types/node": "^25.9.0",
"eslint": "^10.4.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-check-file": "^3.3.1",
"playwright": "^1.60.0",
"prettier": "^3.8.3",
"typescript": "^5.7.0",
Expand Down
6 changes: 3 additions & 3 deletions src/rules/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type {Rule} from '../types.js'
import {filenameAltText} from './filename-alt-text.js'
import {vagueAltText} from './vagueAltText.js'
import {missingAltText} from './missingAltText.js'
import {vagueAltText} from './vague-alt-text.js'
import {missingAltText} from './missing-alt-text.js'
import {placeholderAltText} from './placeholder-alt-text.js'
import {repeatedAltText} from './repeatedAltText.js'
import {repeatedAltText} from './repeated-alt-text.js'

// Append-only registry. Add a rule by importing it here and pushing it onto the array.
export const allRules: Rule[] = [filenameAltText, vagueAltText, missingAltText, placeholderAltText, repeatedAltText]
File renamed without changes.
2 changes: 1 addition & 1 deletion src/rules/placeholder-alt-text.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {Rule, RuleResult, RuleContext} from '../types.js'
import {normalizeAltText} from '../utils/normalizeAltText.js'
import {normalizeAltText} from '../utils/normalize-alt-text.js'

// Known placeholder/boilerplate strings that signal the alt text was never written.
const PLACEHOLDER_ALT_TEXT = new Set([
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {Rule, RuleResult} from '../types.js'
import {normalizeAltText} from '../utils/normalizeAltText.js'
import {normalizeAltText} from '../utils/normalize-alt-text.js'

// Minimum number of consecutive images sharing the same alt before the run is flagged.
const MIN_RUN_LENGTH = 2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {Rule, RuleResult} from '../types.js'
import {normalizeAltText} from '../utils/normalizeAltText.js'
import {normalizeAltText} from '../utils/normalize-alt-text.js'

// Set of words that by themselves, are too vague to be useful alt text
const VAGUE_WORDS = new Set([
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {describe, it, expect} from 'vitest'
import {missingAltText} from '../src/rules/missingAltText.js'
import type {RuleContext} from '../src/types.js'
import {evaluateAlts, makeImage} from './utils/helpers.js'
import {missingAltText} from '../../src/rules/missing-alt-text.js'
import type {RuleContext} from '../../src/types.js'
import {evaluateAlts, makeImage} from '../utils/helpers.js'

describe('missing-alt-text', () => {
it('flags an image with no alt attribute (alt === null)', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {describe, it, expect} from 'vitest'
import {repeatedAltText} from '../src/rules/repeatedAltText.js'
import {evaluateAlts} from './utils/helpers.js'
import {repeatedAltText} from '../../src/rules/repeated-alt-text.js'
import {evaluateAlts} from '../utils/helpers.js'

describe('repeatedAltText', () => {
describe('flags runs at or above the minimum length', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {describe, it, expect} from 'vitest'
import {vagueAltText} from '../src/rules/vagueAltText.js'
import type {RuleContext} from '../src/types.js'
import {evaluateAlts, makeImage} from './utils/helpers.js'
import {vagueAltText} from '../../src/rules/vague-alt-text.js'
import type {RuleContext} from '../../src/types.js'
import {evaluateAlts, makeImage} from '../utils/helpers.js'

describe('vagueAltText', () => {
describe('flags vague single-word alt text', () => {
Expand Down
Loading