Skip to content

Commit

Permalink
bring in filenames match regex to github
Browse files Browse the repository at this point in the history
  • Loading branch information
gracepark committed Nov 25, 2024
1 parent 15639d6 commit c03d25b
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ This config will be interpreted in the following way:
| [async-currenttarget](docs/rules/async-currenttarget.md) | disallow `event.currentTarget` calls inside of async functions | 🔍 | | |
| [async-preventdefault](docs/rules/async-preventdefault.md) | disallow `event.preventDefault` calls inside of async functions | 🔍 | | |
| [authenticity-token](docs/rules/authenticity-token.md) | disallow usage of CSRF tokens in JavaScript | 🔐 | | |
| [filenames-match-regex](docs/rules/filenames-match-regex.md) | ensure filenames match a regex naming convention || | |
| [get-attribute](docs/rules/get-attribute.md) | disallow wrong usage of attribute names | 🔍 | 🔧 | |
| [js-class-name](docs/rules/js-class-name.md) | enforce a naming convention for js- prefixed classes | 🔐 | | |
| [no-blur](docs/rules/no-blur.md) | disallow usage of `Element.prototype.blur()` | 🔍 | | |
Expand Down
4 changes: 1 addition & 3 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const globals = require('globals')
const eslintPlugin = require('eslint-plugin-eslint-plugin')
const importPlugin = require('eslint-plugin-import')
const filenames = require('eslint-plugin-filenames')
const i18nTextPlugin = require('eslint-plugin-i18n-text')
const recommendedGitHub = require('./lib/configs/flat/recommended')
const {fixupPluginRules} = require('@eslint/compat')
Expand All @@ -23,13 +22,12 @@ module.exports = [
plugins: {
eslintPlugin,
importPlugin,
filenamesPlugin: fixupPluginRules(filenames),
'i18n-text': fixupPluginRules(i18nTextPlugin),
},
rules: {
'importPlugin/extensions': 'off',
'importPlugin/no-commonjs': 'off',
'filenamesPlugin/match-regex': 'off',
'github/filenames-match-regex': 'off',
'i18n-text/no-en': 'off',
'eslint-plugin/prefer-placeholders': 'off',
'eslint-plugin/test-case-shorthand-strings': 'off',
Expand Down
3 changes: 2 additions & 1 deletion lib/configs/flat/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const globals = require('globals')
const github = require('../../plugin')
const importPlugin = require('eslint-plugin-import')
const escompatPlugin = require('eslint-plugin-escompat')
const {fixupPluginRules} = require('@eslint/compat')

module.exports = {
...escompatPlugin.configs['flat/recommended'],
Expand All @@ -10,7 +11,7 @@ module.exports = {
...globals.browser,
},
},
plugins: {importPlugin, escompatPlugin, github},
plugins: {importPlugin, escompatPlugin, github: fixupPluginRules(github)},
rules: {
'escompatPlugin/no-dynamic-imports': 'off',
'github/async-currenttarget': 'error',
Expand Down
3 changes: 2 additions & 1 deletion lib/configs/flat/internal.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const github = require('../../plugin')
const {fixupPluginRules} = require('@eslint/compat')

module.exports = {
plugins: {github},
plugins: {github: fixupPluginRules(github)},
rules: {
'github/authenticity-token': 'error',
'github/js-class-name': 'error',
Expand Down
3 changes: 2 additions & 1 deletion lib/configs/flat/react.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const github = require('../../plugin')
const jsxA11yPlugin = require('eslint-plugin-jsx-a11y')
const {fixupPluginRules} = require('@eslint/compat')

module.exports = {
...jsxA11yPlugin.flatConfigs.recommended,
Expand All @@ -11,7 +12,7 @@ module.exports = {
},
},
},
plugins: {github, jsxA11yPlugin},
plugins: {github: fixupPluginRules(github), jsxA11yPlugin},
rules: {
'jsxA11yPlugin/role-supports-aria-props': 'off', // Override with github/a11y-role-supports-aria-props until https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/910 is resolved
'github/a11y-aria-label-is-well-formatted': 'error',
Expand Down
6 changes: 2 additions & 4 deletions lib/configs/flat/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const github = require('../../plugin')
const prettierPlugin = require('eslint-plugin-prettier')
const eslintComments = require('eslint-plugin-eslint-comments')
const importPlugin = require('eslint-plugin-import')
const filenames = require('eslint-plugin-filenames')
const i18nTextPlugin = require('eslint-plugin-i18n-text')
const noOnlyTestsPlugin = require('eslint-plugin-no-only-tests')
const {fixupPluginRules} = require('@eslint/compat')
Expand All @@ -17,13 +16,12 @@ module.exports = {
},
},
plugins: {
filenamesPlugin: fixupPluginRules(filenames),
prettierPlugin,
eslintComments,
importPlugin,
'i18n-text': fixupPluginRules(i18nTextPlugin),
noOnlyTestsPlugin,
github,
github: fixupPluginRules(github),
},
rules: {
'constructor-super': 'error',
Expand All @@ -34,7 +32,7 @@ module.exports = {
'eslintComments/no-unused-disable': 'error',
'eslintComments/no-unused-enable': 'error',
'eslintComments/no-use': ['error', {allow: ['eslint', 'eslint-disable-next-line', 'eslint-env', 'globals']}],
'filenamesPlugin/match-regex': ['error', '^[a-z0-9-]+(.[a-z0-9-]+)?$'],
'github/filenames-match-regex': ['error', '^[a-z0-9-]+(.[a-z0-9-]+)?$'],
'func-style': ['error', 'declaration', {allowArrowFunctions: true}],
'github/array-foreach': 'error',
'github/no-implicit-buggy-globals': 'error',
Expand Down
3 changes: 2 additions & 1 deletion lib/configs/flat/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ const eslint = require('@eslint/js')
const tseslint = require('typescript-eslint')
const escompatPlugin = require('eslint-plugin-escompat')
const github = require('../../plugin')
const {fixupPluginRules} = require('@eslint/compat')

module.exports = tseslint.config(eslint.configs.recommended, ...tseslint.configs.recommended, {
languageOptions: {
parser: tseslint.parser,
},
plugins: {'@typescript-eslint': tseslint.plugin, escompatPlugin, github},
plugins: {'@typescript-eslint': tseslint.plugin, escompatPlugin, github: fixupPluginRules(github)},
rules: {
camelcase: 'off',
'no-unused-vars': 'off',
Expand Down
2 changes: 1 addition & 1 deletion lib/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
'eslint-comments/no-unused-disable': 'error',
'eslint-comments/no-unused-enable': 'error',
'eslint-comments/no-use': ['error', {allow: ['eslint', 'eslint-disable-next-line', 'eslint-env', 'globals']}],
'filenames/match-regex': ['error', '^[a-z0-9-]+(.[a-z0-9-]+)?$'],
'github/filenames-match-regex': ['error', '^[a-z0-9-]+(.[a-z0-9-]+)?$'],
'func-style': ['error', 'declaration', {allowArrowFunctions: true}],
'github/array-foreach': 'error',
'github/no-implicit-buggy-globals': 'error',
Expand Down
1 change: 1 addition & 0 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
'async-currenttarget': require('./rules/async-currenttarget'),
'async-preventdefault': require('./rules/async-preventdefault'),
'authenticity-token': require('./rules/authenticity-token'),
'filenames-match-regex': require('./rules/filenames-match-regex'),
'get-attribute': require('./rules/get-attribute'),
'js-class-name': require('./rules/js-class-name'),
'no-blur': require('./rules/no-blur'),
Expand Down
8 changes: 4 additions & 4 deletions test-examples/flat/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import github from 'eslint-plugin-github'

export default [
github.getFlatConfigs().browser,
github.getFlatConfigs().recommended,
github.getFlatConfigs().react,
...github.getFlatConfigs().typescript,
// github.getFlatConfigs().recommended,
// github.getFlatConfigs().react,
// ...github.getFlatConfigs().typescript,
{
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
ignores: ['eslint.config.mjs'],
rules: {
'github/array-foreach': 'error',
'github/async-preventdefault': 'warn',
'github/no-then': 'error',
'github/no-blur': 'error',
'github/async-preventdefault': 'error',
},
},
]
2 changes: 1 addition & 1 deletion test-examples/flat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@eslint/js": "^9.5.0",
"@types/node": "^20.14.5",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"eslint": "^9.14.0",
"eslint-plugin-github": "file:../..",
"typescript": "^5.6.3",
"typescript-eslint": "^8.12.2"
Expand Down

0 comments on commit c03d25b

Please sign in to comment.