Skip to content

Commit

Permalink
feat: support formatjs eslint rules
Browse files Browse the repository at this point in the history
This adds support for formatjs eslint rules, and
adds an `eslint-next`config which includes a rule
that ensures all translation source strings have
descriptions.
  • Loading branch information
brian-smith-tcril committed Mar 11, 2024
1 parent 35415fe commit 17081e6
Show file tree
Hide file tree
Showing 4 changed files with 415 additions and 0 deletions.
48 changes: 48 additions & 0 deletions config/.eslintrc.next.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// This file will be removed and replace "eslintrc.js" once all MFEs are ready
const { babel } = require('../lib/presets');

module.exports = {
plugins: ['formatjs'],
extends: '@edx/eslint-config',
parser: '@babel/eslint-parser',
parserOptions: {
requireConfigFile: true,
babelOptions: {
configFile: babel.resolvedFilepath || babel.defaultFilepath,
},
},
rules: {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/*.config.*',
'**/*.test.*',
'**/setupTest.js',
],
},
],
'import/no-unresolved': [
'error',
{
ignore: [
'env.config',
],
},
],
// https://github.com/evcohen/eslint-plugin-jsx-a11y/issues/340#issuecomment-338424908
'jsx-a11y/anchor-is-valid': ['error', {
components: ['Link'],
specialLink: ['to'],
}],
'formatjs/enforce-description': ['error', 'literal'],
'import/no-import-module-export': 'off',
'react/function-component-definition': [2, { namedComponents: 'arrow-function' }],
},
globals: {
newrelic: false,
},
ignorePatterns: [
'module.config.js',
],
};
8 changes: 8 additions & 0 deletions lib/presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ const eslint = new ConfigPreset({
searchFilepaths,
});

// This will be removed and replace "eslint" once all MFEs are ready
const eslintNext = new ConfigPreset({
defaultFilename: '.eslintrc.next.js',
searchFilenames: ['.eslintrc.next', '.eslintrc.next.js'],
searchFilepaths,
});

const jest = new ConfigPreset({
defaultFilename: 'jest.config.js',
searchFilenames: ['jest.config.js'],
Expand Down Expand Up @@ -63,6 +70,7 @@ module.exports = {
'babel-preserve-modules': babelPreserveModules,
'babel-typescript': babelTypescript,
eslint,
'eslint-next': eslintNext, // This will be removed and replace "eslint" once all MFEs are ready
jest,
webpack,
webpackDevServer,
Expand Down
Loading

0 comments on commit 17081e6

Please sign in to comment.